From af02d1da58db9805eb63d495c8ff1eb8e5d6f902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Tue, 23 Apr 2019 07:07:57 +0000 Subject: [PATCH] [FIX] website_forum: remove unnecessary slow code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit 56645335b7bae0415242ec51193e493119a58879 the subtype `gamification.mt_badge_granted` is not used anymore. Therefore this method will never return anything. However, it is very costly on performance, and it is run on every page of the forum! The problematic performance point is that `needaction` is a computed field, which implies all existing `mail.message` having the target subtype have to be fetched to compute this field, which obviously does not scale well at all. closes odoo/odoo#32861 Signed-off-by: Jérémy Kersten (jke) --- addons/website_forum/controllers/main.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index ac84166d528..221128b2ab0 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -22,12 +22,8 @@ class WebsiteForum(http.Controller): _user_per_page = 30 def _get_notifications(self): - badge_subtype = request.env.ref('gamification.mt_badge_granted') - if badge_subtype: - msg = request.env['mail.message'].search([('subtype_id', '=', badge_subtype.id), ('needaction', '=', True)]) - else: - msg = list() - return msg + """Deprecated""" + return list() def _prepare_forum_values(self, forum=None, **kwargs): values = {