Commit 313a7a66 authored by Rémy Coutable's avatar Rémy Coutable Committed by Imre Farkas

Fallback to `created_at` when `merged_at` is missing in Insights charts

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent c1477461
......@@ -287,6 +287,11 @@ The `period_field` is automatically set to:
- `merged_at` if `query.issuable_state` is `merged`
- `created_at` otherwise
NOTE: **Note:**
Until [this bug](https://gitlab.com/gitlab-org/gitlab/-/issues/26911), is resolved, you may see `created_at`
in place of `merged_at`.
`created_at` will be used instead.
### `projects`
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/10904) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.4.
......
---
title: Fallback to `created_at` when `merged_at` is missing in Insights charts
merge_request: 36930
author:
type: fixed
......@@ -62,7 +62,8 @@ module Gitlab
# }
def issuables_grouped_by_normalized_period
@issuables_grouped_by_normalized_period ||= issuables.group_by do |issuable|
normalized_time(issuable.public_send(period_field)) # rubocop:disable GitlabSecurity/PublicSend
time_field = issuable.public_send(period_field) || issuable.created_at # rubocop:disable GitlabSecurity/PublicSend
normalized_time(time_field)
end
end
......
......@@ -133,9 +133,9 @@ RSpec.describe Gitlab::Insights::Reducers::CountPerPeriodReducer do
context 'with merged merge requests' do
include_context 'Insights merge requests reducer context', :merged
# Populate the MR metrics' merged_at
# Populate the MR metrics' merged_at, except for issuable3 to reproduce a real use-case where merged_at is null.
before do
(0..3).each do |i|
(0..2).each do |i|
merge_request = public_send("issuable#{i}")
merge_request_metrics_service = MergeRequestMetricsService.new(merge_request.metrics)
Event.transaction do
......
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