Skip to content

Update Timeline event update mutation to consider timeline event tags

Rajendra Kadam requested to merge 373853-incident-tag-timeline-event-update into master

What does this MR do and why?

This MR adds support to update timeline event tags on a timeline event.

The way this works is the API expects the net result of tag updates to do on a timeline event.

For example, assume there are event1, tag1, tag2, and tag3 on a project. event1 is already assigned with tag1. We need to update it with tag3. So from the front end, I will get [tag1, tag3]. So I compute the tags to add and tags to remove and assign/unassign them accordingly. If I have to delete the assigned tags on event1, then the frontend passes me the [] tags value. This means, we need to delete all tag links to the event and it will not have any assigned tags. If the value for tags from frontend is the same as the assigned tags, then I do not perform any operation regarding tag updates on the event.

Query plan for the scopes

  1. by_names: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13345/commands/46839
  2. timeline_event.timeline_event_tags: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13345/commands/46840

Mutation

Sample mutation

mutation UpdateTimelineEvent($input: TimelineEventUpdateInput!) {
  timelineEventUpdate(input: $input) {
    timelineEvent {
      id
      note
      timelineEventTags {
        nodes {
          name
        }
      }
    }
    errors
  }
}

Sample input

{
  "input": {
    "id": "<global id of the incident>",
    "note":"<strong>Updated note</strong>",
    "occurredAt": "2022-01-25T11:38:05Z",
    "timelineEventTagNames": [<name of the tag>]
  }
}

How to set up and validate locally

  1. Make sure you have maintainer access to a project.
  2. Create some tags using GraphQL by following the steps mentioned in !102870 (merged)
  3. Create a timeline event using the UI by following the steps mentioned in the docs.
  4. Get the global id of the above timeline event from the console using IncidentManagement::TimelineEvent.last.to_global_id.
  5. Follow the update mutation above with the above sample input to update the event.
  6. Pass some non-existing tags, remove some tags, add some tags using the API and check the result.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #373853 (closed)

Edited by Rajendra Kadam

Merge request reports