social/mail_tracking/models
Jairo Llopis fa7cf1ef80 [FIX] mail_tracking: performance fix
When searching for failed messages, [this line][1] made Odoo search messages in 2 steps:

1. Find which `mail.tracking.email` records are in those states.
2. Find which of them belong to the present `mail.message` records.

Step 2 could take a long time if there were a lot of failures in a DB. In our proven case, this made loading the `res.partner` form view take about ~6s per partner. It was also slowing down other views.

With this simple fix, [that nasty line linked above][1] is solved with just one query like this:

```SQL
SELECT "mail_message".id FROM "mail_tracking_email" as "mail_message__mail_tracking_ids","mail_message"
WHERE ("mail_message"."id"="mail_message__mail_tracking_ids"."maiL_message_id") AND (((("mail_message"."model" = 'res.partner')  AND ("mail_message"."mail_tracking_needs_action" = true))  AND  ("mail_message__mail_tracking_ids"."state" in ('rejected','error','bounced','soft-bounced','spam')))  AND  ("mail_message"."res_id" in (1000)))
ORDER BY "mail_message"."id" DESC
```

Thus this makes the forms load at normal speed again.

[1]: 8bd98212b8/mail_tracking/models/mail_thread.py (L25)
2020-07-23 12:53:26 +02:00
..
__init__.py [IMP] mail_tracking: Ignore catchall 2020-04-22 16:26:08 +02:00
ir_config_parameter.py [IMP] mail_tracking: Ignore catchall 2020-04-22 16:26:08 +02:00
ir_mail_server.py [FIX] mail_tracking: do not slurp exceptions 2020-06-24 10:48:00 +01:00
mail_alias.py [IMP] mail_tracking: Ignore catchall 2020-04-22 16:26:08 +02:00
mail_bounced_mixin.py fixup! [IMP] mail_tracking: Failed Messages to 12.0 2019-11-07 12:53:57 +01:00
mail_mail.py fixup! [IMP] mail_tracking: Failed Messages to 12.0 2019-10-29 13:01:21 +01:00
mail_message.py [FIX] mail_tracking: performance fix 2020-07-23 12:53:26 +02:00
mail_resend_message.py [FIX] mail_tracking: Refresh thread widget when sets a message as reviewed 2019-11-15 20:55:41 +01:00
mail_thread.py [IMP] mail_tracking: Use 'self' directly 2020-03-25 15:40:25 +01:00
mail_tracking_email.py fixup! [IMP] mail_tracking: Failed Messages to 12.0 2019-11-12 18:26:53 +01:00
mail_tracking_event.py [MIG] mail_tracking: Migration to 11.0 2018-12-18 12:31:00 -05:00
res_partner.py [MIG] mail_tracking: Migration to 12.0 2019-01-07 02:40:06 -05:00