summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-18 10:13:42 +0100
committerJames Lopez <james@jameslopez.es>2016-11-18 10:13:42 +0100
commitcd222357ade5f47f8d52f22dea66965c580a5843 (patch)
treea3eef5f83153499608a9985601aae1066f426897
parente56c305be003ee33b093f9ba42622fba0da903f2 (diff)
downloadgitlab-ce-cd222357ade5f47f8d52f22dea66965c580a5843.tar.gz
refactor events
-rw-r--r--lib/gitlab/cycle_analytics/test_event.rb20
-rw-r--r--spec/lib/gitlab/cycle_analytics/production_event_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/review_event_spec.rb8
3 files changed, 12 insertions, 26 deletions
diff --git a/lib/gitlab/cycle_analytics/test_event.rb b/lib/gitlab/cycle_analytics/test_event.rb
index 00404d7f6b0..d553d0b5aec 100644
--- a/lib/gitlab/cycle_analytics/test_event.rb
+++ b/lib/gitlab/cycle_analytics/test_event.rb
@@ -1,26 +1,12 @@
module Gitlab
module CycleAnalytics
- class TestEvent < BaseEvent
+ class TestEvent < StagingEvent
def initialize(*args)
+ super(*args)
+
@stage = :test
@start_time_attrs = mr_metrics_table[:latest_build_started_at]
@end_time_attrs = mr_metrics_table[:latest_build_finished_at]
- @projections = [build_table[:id]]
- @order = build_table[:created_at]
-
- super(*args)
- end
-
- def custom_query(base_query)
- base_query.join(build_table).on(mr_metrics_table[:pipeline_id].eq(build_table[:commit_id]))
- end
-
- private
-
- def serialize(event)
- build = ::Ci::Build.find(event['id'])
-
- AnalyticsBuildSerializer.new.represent(build).as_json
end
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/production_event_spec.rb b/spec/lib/gitlab/cycle_analytics/production_event_spec.rb
index 6ee54f246a7..5d12365c430 100644
--- a/spec/lib/gitlab/cycle_analytics/production_event_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/production_event_spec.rb
@@ -2,9 +2,9 @@ require 'spec_helper'
require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::ProductionEvent do
- it_behaves_like 'default query config'
-
- it 'has the default order' do
- expect(event.order).to eq(event.start_time_attrs)
+ it_behaves_like 'default query config' do
+ it 'has the default order' do
+ expect(event.order).to eq(event.start_time_attrs)
+ end
end
-end
+end \ No newline at end of file
diff --git a/spec/lib/gitlab/cycle_analytics/review_event_spec.rb b/spec/lib/gitlab/cycle_analytics/review_event_spec.rb
index 890e3ab3078..1ff53aa0227 100644
--- a/spec/lib/gitlab/cycle_analytics/review_event_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/review_event_spec.rb
@@ -2,9 +2,9 @@ require 'spec_helper'
require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe Gitlab::CycleAnalytics::ReviewEvent do
- it_behaves_like 'default query config'
-
- it 'has the default order' do
- expect(event.order).to eq(event.start_time_attrs)
+ it_behaves_like 'default query config' do
+ it 'has the default order' do
+ expect(event.order).to eq(event.start_time_attrs)
+ end
end
end