]> git.ipfire.org Git - thirdparty/patchwork.git/commit
parser: avoid an unnecessary UPDATE of Person
authorDaniel Axtens <dja@axtens.net>
Sun, 18 Feb 2018 08:06:23 +0000 (19:06 +1100)
committerDaniel Axtens <daniel.axtens@canonical.com>
Tue, 6 Mar 2018 14:32:42 +0000 (01:32 +1100)
commite11b7165025fbd38d473d40133bba9a038d293cf
treee4e4840004027a3971b183f1376a457a1399bbda
parentf78161a552960301be5b9d70be51319105ff094a
parser: avoid an unnecessary UPDATE of Person

Analysis of SQL statements showed that when parsing an email, the row
for the Person who sent the email was always getting updated. This is
because the test for updating it only checks if the incoming mail has
*a* name attached to the email address, and not if it has a new name.
Django is not smart enough to figure that out, and so unconditionally
UPDATEs the model when asked to save.

Give it a hand - only update the model and save it if the new name is
in fact different.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
patchwork/parser.py