]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
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)
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

index 463f05177ecdd28f99af13c5eaa0809694a88281..6c716036e775f78e696c59076d7050c9a5567cf3 100644 (file)
@@ -362,7 +362,7 @@ def get_or_create_author(mail):
                                           defaults={'name': name,
                                                     'email': email})[0]
 
-    if name:  # use the latest provided name
+    if name and name != person.name:  # use the latest provided name
         person.name = name
         person.save()