[FIX] website_mail_channel: filter on found channel
Before this commit, controller did 1. search all channels with an alias 2. search on the messages on mail.channel 3. map the number of messages with the channels The issue was that the list of messages in step 2 includes more channels than the ones found in step 1. The list of messages may be very big and some groups may be retrieved while not used in the small list of channels with an alias. This commit should improve performances while accessing the /groups page. closes odoo/odoo#52593 X-original-commit: 60e806f4ea8ce75390eb59620ec61a39b4d3ccd2 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
This commit is contained in:
@@ -44,9 +44,12 @@ class MailGroup(http.Controller):
|
||||
|
||||
# compute statistics
|
||||
month_date = datetime.today() - relativedelta.relativedelta(months=1)
|
||||
messages = request.env['mail.message'].read_group(
|
||||
[('model', '=', 'mail.channel'), ('date', '>=', fields.Datetime.to_string(month_date)), ('message_type', '!=', 'notification')],
|
||||
[], ['res_id'])
|
||||
messages = request.env['mail.message'].read_group([
|
||||
('model', '=', 'mail.channel'),
|
||||
('date', '>=', fields.Datetime.to_string(month_date)),
|
||||
('message_type', '!=', 'notification'),
|
||||
('res_id', 'in', groups.ids),
|
||||
], ['res_id'], ['res_id'])
|
||||
message_data = dict((message['res_id'], message['res_id_count']) for message in messages)
|
||||
|
||||
group_data = dict(
|
||||
|
||||
Reference in New Issue
Block a user