Commit b37d1b7a authored by Damien Lespiau's avatar Damien Lespiau
Browse files

patch: Reuse orig_patch instead of querying the patch object again



When reviewing the patch-state-change series, I didn't notice that we
were doing an extra request we could have avoided.

Also align the parameters to the opening brace.
Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
parent 162df88b
......@@ -842,19 +842,18 @@ def _patch_change_callback(sender, instance, **kwargs):
curr_user = threadlocalrequest.get_current_user()
previous_state = str(orig_patch.state)
new_state = str(instance.state)
changed_patch = Patch.objects.get(pk=instance.pk)
# Do not log patch-state-change events for Patches that are not part of a
# Series (ie patches older than the introduction of Series)
series = find_series_for_patch(orig_patch)
if series:
log = EventLog(event=event_state_change,
user=curr_user,
series_id=series.id,
patch=changed_patch,
parameters={'previous_state': previous_state,
'new_state': new_state,
})
user=curr_user,
series_id=series.id,
patch=orig_patch,
parameters={'previous_state': previous_state,
'new_state': new_state,
})
log.save()
if not instance.project.send_notifications:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment