diff options
author | Adam Hegyi <ahegyi@gitlab.com> | 2019-09-05 11:00:41 +0200 |
---|---|---|
committer | Adam Hegyi <ahegyi@gitlab.com> | 2019-09-05 17:06:26 +0200 |
commit | 1853ad09fd41c74da3c1b80d0ba929274073d278 (patch) | |
tree | 1467aa38d1de79ccb83eee6175d0728da34be1ec /spec/lib | |
parent | a0b3bc3de3e052ac0dcbe79cfcfcfc4c65198492 (diff) | |
download | gitlab-ce-new-cycle-analytics-query-backend.tar.gz |
Skip duration filter when it is unnecessarynew-cycle-analytics-query-backend
- Introduce DurationFilter class that decides whether we need
additional filtering to avoid negative durations
- Improve a queries after checking the execution plan
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/analytics/cycle_analytics/duration_filter_spec.rb | 22 | ||||
-rw-r--r-- | spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb | 4 |
2 files changed, 24 insertions, 2 deletions
diff --git a/spec/lib/gitlab/analytics/cycle_analytics/duration_filter_spec.rb b/spec/lib/gitlab/analytics/cycle_analytics/duration_filter_spec.rb new file mode 100644 index 00000000000..33309181db4 --- /dev/null +++ b/spec/lib/gitlab/analytics/cycle_analytics/duration_filter_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Analytics::CycleAnalytics::DurationFilter do + let(:stage_params) { {} } + let(:stage) { Analytics::CycleAnalytics::ProjectStage.new(stage_params) } + subject { described_class.new(stage: stage) } + + describe 'when duration filtering is skipped' do + %I[issue test review staging production].each do |stage_name| + it "for '#{stage_name}' stage" do + stage_params.merge!(Gitlab::Analytics::CycleAnalytics::DefaultStages.public_send("params_for_#{stage_name}_stage")) + + input_query = stage.subject_model.all + output_query = subject.apply(input_query) + + expect(input_query).to eq(output_query) + end + end + end +end diff --git a/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb b/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb index 8530b50be0a..0e34bf1ffc2 100644 --- a/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb +++ b/spec/lib/gitlab/analytics/cycle_analytics/records_fetcher_spec.rb @@ -78,8 +78,8 @@ describe Gitlab::Analytics::CycleAnalytics::RecordsFetcher do end describe 'special case' do - let(:mr1) { create(:merge_request, source_project: project, allow_broken: true) } - let(:mr2) { create(:merge_request, source_project: project, allow_broken: true) } + let(:mr1) { create(:merge_request, source_project: project, allow_broken: true, created_at: 20.days.ago) } + let(:mr2) { create(:merge_request, source_project: project, allow_broken: true, created_at: 20.days.ago) } let(:ci_build1) { create(:ci_build) } let(:ci_build2) { create(:ci_build) } let(:default_stages) { Gitlab::Analytics::CycleAnalytics::DefaultStages } |