Skip to content

Use ResourceLabelEvent for tracking label changes

Jan Provaznik requested to merge label-event into master

What does this MR do?

Uses ResourceLabelEvent model for tracking label changes on issuables instead of creating system note.

This makes it tricky to display label changes notes as it used to be because we have to mix records from Note model with records from ResourceLabelEvent model, and also we have to squash multiple label events together (https://gitlab.com/gitlab-org/gitlab-ce/issues/48483#scenario-5).

To make rendering of these label event possible without dramatic frontend changes, an unsaved/syntehtic Note is created to represent label changes when displaying resource's notes. Because these syntehtic notes are not saved and don't have real note ID, a discussion ID is used as note ID for them.

Label events are mixed with classic notes only for displaying in web UI, in API label events are listed separately.

This has some implications for notes/discussions on frontend side:

  • note ID is now string - (e.g. '123' for 'real' notes, or SHA '5309ce673a0ae2dda0b9813f1602d5ffc5a7026f' for label event notes)
  • note user can be null for label event notes - in that case A deleted user is displayed in UI

Caching

Rendering notes for label events had performance issue (see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21281#note_96372665), to mitigate both time and number of queries, rendered html fragments for each label event are cached.

Known Issues

What are the relevant issue numbers?

Closes #48483 (closed)

Does this MR meet the acceptance criteria?

Edited by Jan Provaznik

Merge request reports