[PATCH v2 0/3] Store the 'actor' responsible for events

Johan Herland johan at herland.net
Tue Oct 8 09:16:42 AEDT 2019

The V4L project (https://patchwork.linuxtv.org) uses patch states and
delegates extensively to track progress. We want an audit log to keep
track of the changes made to these patch fields. The Event model already
records this information, but leaves out one crucial detail: which
maintainer/user actually updated the patch state/delegate. The need for
this enhancement is also documented in Issue #73.

This patch series adds an 'actor' field to the Event model, and - for
applicable events - stores the user responsible for that event (i.e. the
current/active user, if any) into this field.

This applies to the following events:
 - patch-created
 - patch-completed
 - patch-state-changed
 - patch-delegated
 - series-completed
 - check-created

For the other events (cover-created and series-created), I could not
easily determine if there is a responsible user at all, as these events
are typically generated in response to incoming emails. In these cases
(and any other scenario where we cannot find the active/current user)
the Event.actor field is left as null/None.

Finally, the new Event.actor field is exposed in the events view of the
REST API (as of API version 1.2).

Changes since v1:
 - Rename Event field from 'user' to 'actor'
 - Add 'Closes: #73' to patch #2.
 - Store actor for check-created as well. Assume actor == check.user
 - Leave 'actor' out of API docs pre-v1.2
 - Add test that delegates a Patch via the REST API, and verifies that
   the resulting event has the correct 'actor' set.

There is still an open discussion as to whether the strategy used in
patch #2 to determine the actor and forward it to the event creation,
is the way we want to go.

Have fun!

Johan Herland (3):
  models.Event: Add the user responsible for the event
  Include the responsible actor in applicable events
  /api/events: Add 'actor' field to generated JSON

 docs/api/schemas/latest/patchwork.yaml   |  6 ++++++
 docs/api/schemas/patchwork.j2            |  8 ++++++++
 docs/api/schemas/v1.2/patchwork.yaml     |  6 ++++++
 patchwork/api/event.py                   | 10 +++++++---
 patchwork/migrations/0037_event_actor.py | 21 +++++++++++++++++++++
 patchwork/models.py                      | 10 +++++++++-
 patchwork/signals.py                     | 10 ++++++++--
 patchwork/tests/api/test_event.py        | 24 ++++++++++++++++++++++++
 patchwork/tests/test_events.py           |  7 +++++++
 9 files changed, 96 insertions(+), 6 deletions(-)
 create mode 100644 patchwork/migrations/0037_event_actor.py


More information about the Patchwork mailing list