VSA - Support calculating cumulative durations
## Problem statement The Value Stream Analytics feature uses 2 events to determine the duration of the item (issue or merge request) in a given stage. - Start event timestamp (for example: issue created) - End event timestamp (for example: issue closed) In some cases these events occur several times during the lifecycle of the issue or merge request, for example, when a MR jumps from development to review states a few times (label changes). The current implementation of VSA doesn't support calculating the cumulative duration. Consider the following case: - Start event: "review" label added - End Event: "review" label removed Events: - "review" label added: 2022-10-01 - "review" label removed: 2022-10-05 - "review" label added: 2022-11-01 - "review label removed: 2022-11-03 From these events: - Start event time: 2022-10-01 - End event time: 2022-11-03 Durations: - Duration based on the current implementation: 33 days - Duration after cumulative durations implemented: 8 (5+3) days ## Proposal Extend the VSA query backend to optionally return an array of timestamps for a given event instead of a single value. During data ingestion (DateLoaderService), the backend attempts (best-effort) to calculate the correct durations between 2 timestamp arrays. The solution should also work for existing events where returning an array is not possible, for example the issue creation date never changes but with a generic implementation it gives the possibility to implement such calculations for the rest of the events if needed. This epic mainly focuses on fixing the label-based stage durations but the implementation should be generic enough to support other events in the future.
epic