Skip to content

Commit e11b716

Browse files
committed
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 <[email protected]> Reviewed-by: Stephen Finucane <[email protected]> Signed-off-by: Daniel Axtens <[email protected]>
1 parent f78161a commit e11b716

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

patchwork/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def get_or_create_author(mail):
345345
defaults={'name': name,
346346
'email': email})[0]
347347

348-
if name: # use the latest provided name
348+
if name and name != person.name: # use the latest provided name
349349
person.name = name
350350
person.save()
351351

0 commit comments

Comments
 (0)