Feature #1437
Updated by liaham 9 months ago
Currently, news will be queried with every request since the notification info is located in the apps header. request. This could have an impact on performance. Therefore, the query result should be cached until there is a new news created. Here is an example of the query from the logs: ```shell (0.5ms) SELECT `news_notifications`.`news_id` FROM `news_notifications` WHERE `news_notifications`.`user_id` = 1 ↳ plugins/redmine_news_notification/app/models/news_notification.rb:47:in `read_ids' SQL (0.7ms) SELECT `news`.`id` AS t0_r0, `news`.`project_id` AS t0_r1, `news`.`title` AS t0_r2, `news`.`summary` AS t0_r3, `news`.`description` AS t0_r4, `news`.`author_id` AS t0_r5, `news`.`created_on` AS t0_r6, `news`.`comments_count` AS t0_r7, `users`.`id` AS t1_r0, `users`.`login` AS t1_r1, `users`.`hashed_password` AS t1_r2, `users`.`firstname` AS t1_r3, `users`.`lastname` AS t1_r4, `users`.`admin` AS t1_r5, `users`.`status` AS t1_r6, `users`.`last_login_on` AS t1_r7, `users`.`language` AS t1_r8, `users`.`auth_source_id` AS t1_r9, `users`.`created_on` AS t1_r10, `users`.`updated_on` AS t1_r11, `users`.`type` AS t1_r12, `users`.`mail_notification` AS t1_r13, `users`.`salt` AS t1_r14, `users`.`must_change_passwd` AS t1_r15, `users`.`passwd_changed_on` AS t1_r16, `users`.`twofa_scheme` AS t1_r17, `users`.`twofa_totp_key` AS t1_r18, `users`.`twofa_totp_last_used_at` AS t1_r19, `users`.`twofa_required` AS t1_r20, `users`.`privacy_consent` AS t1_r21, `projects`.`id` AS t2_r0, `projects`.`name` AS t2_r1, `projects`.`description` AS t2_r2, `projects`.`homepage` AS t2_r3, `projects`.`is_public` AS t2_r4, `projects`.`parent_id` AS t2_r5, `projects`.`created_on` AS t2_r6, `projects`.`updated_on` AS t2_r7, `projects`.`identifier` AS t2_r8, `projects`.`status` AS t2_r9, `projects`.`lft` AS t2_r10, `projects`.`rgt` AS t2_r11, `projects`.`inherit_members` AS t2_r12, `projects`.`default_version_id` AS t2_r13, `projects`.`default_assigned_to_id` AS t2_r14, `projects`.`default_issue_query_id` AS t2_r15, `projects`.`dmsf_description` AS t2_r16, `projects`.`dmsf_notification` AS t2_r17, `projects`.`dmsf_act_as_attachable` AS t2_r18, `projects`.`default_dmsf_query_id` AS t2_r19, `projects`.`project_type_id` AS t2_r20, `projects`.`is_project_type` AS t2_r21 FROM `news` INNER JOIN `projects` ON `projects`.`id` = `news`.`project_id` LEFT OUTER JOIN `users` ON `users`.`id` = `news`.`author_id` AND `users`.`type` = 'User' WHERE (projects.status <> 9 AND projects.status <> 10 AND EXISTS (SELECT 1 AS one FROM enabled_modules em WHERE em.project_id = projects.id AND em.name='news')) AND (news.id not in (0) and news.author_id != 1 and news.created_on > '2006-07-19 19:12:21') ORDER BY news.created_on DESC LIMIT 100 ↳ plugins/redmine_news_notification/app/models/news_notification.rb:27:in `map' ```