Commit db02af3e authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix/cycle-analytics-plan-issue' into 'master'

Fix cycle analytics plan stage when commits are missing

Takes into account when commits are `nil` so the app doesn't throw an exception and also removes them.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/24836

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)


See merge request !7694
parents 9f7fc6a0 b938aa5c
---
title: Fix cycle analytics plan stage when commits are missing
merge_request:
author:
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
event_result.map do |event| event_result.map do |event|
serialize(event) if has_permission?(event['id']) serialize(event) if has_permission?(event['id'])
end end.compact
end end
def custom_query(_base_query); end def custom_query(_base_query); end
......
...@@ -27,6 +27,8 @@ module Gitlab ...@@ -27,6 +27,8 @@ module Gitlab
end end
def first_time_reference_commit(commits, event) def first_time_reference_commit(commits, event)
return nil if commits.blank?
YAML.load(commits).find do |commit| YAML.load(commits).find do |commit|
next unless commit[:committed_date] && event['first_mentioned_in_commit_at'] next unless commit[:committed_date] && event['first_mentioned_in_commit_at']
......
...@@ -6,5 +6,13 @@ describe Gitlab::CycleAnalytics::PlanEvent do ...@@ -6,5 +6,13 @@ describe Gitlab::CycleAnalytics::PlanEvent do
it 'has the default order' do it 'has the default order' do
expect(event.order).to eq(event.start_time_attrs) expect(event.order).to eq(event.start_time_attrs)
end end
context 'no commits' do
it 'does not blow up if there are no commits' do
allow_any_instance_of(Gitlab::CycleAnalytics::EventsQuery).to receive(:execute).and_return([{}])
expect { event.fetch }.not_to raise_error
end
end
end end
end end
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