]> 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:24:18 +0000 (01:24 +1100)
commitfa535a8e2209e13abf2ef3d42514681e2abb3777
tree78f668f7b747f6b07f91110d0962fc0957414991
parentc4eca471a4a2cc3a2438e3ee6061df8988a251a6
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