From: Daniel Axtens Date: Sun, 18 Feb 2018 08:06:23 +0000 (+1100) Subject: parser: avoid an unnecessary UPDATE of Person X-Git-Tag: v2.0.2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e11b7165025fbd38d473d40133bba9a038d293cf;p=thirdparty%2Fpatchwork.git 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 Reviewed-by: Stephen Finucane Signed-off-by: Daniel Axtens --- diff --git a/patchwork/parser.py b/patchwork/parser.py index 6be37ec6..f84f905d 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -345,7 +345,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()