refactor events
This commit is contained in:
parent
e56c305be0
commit
cd222357ad
3 changed files with 12 additions and 26 deletions
|
@ -1,26 +1,12 @@
|
||||||
module Gitlab
|
module Gitlab
|
||||||
module CycleAnalytics
|
module CycleAnalytics
|
||||||
class TestEvent < BaseEvent
|
class TestEvent < StagingEvent
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
|
super(*args)
|
||||||
|
|
||||||
@stage = :test
|
@stage = :test
|
||||||
@start_time_attrs = mr_metrics_table[:latest_build_started_at]
|
@start_time_attrs = mr_metrics_table[:latest_build_started_at]
|
||||||
@end_time_attrs = mr_metrics_table[:latest_build_finished_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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,9 @@ require 'spec_helper'
|
||||||
require 'lib/gitlab/cycle_analytics/shared_event_spec'
|
require 'lib/gitlab/cycle_analytics/shared_event_spec'
|
||||||
|
|
||||||
describe Gitlab::CycleAnalytics::ProductionEvent do
|
describe Gitlab::CycleAnalytics::ProductionEvent do
|
||||||
it_behaves_like 'default query config'
|
it_behaves_like 'default query config' 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
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -2,9 +2,9 @@ require 'spec_helper'
|
||||||
require 'lib/gitlab/cycle_analytics/shared_event_spec'
|
require 'lib/gitlab/cycle_analytics/shared_event_spec'
|
||||||
|
|
||||||
describe Gitlab::CycleAnalytics::ReviewEvent do
|
describe Gitlab::CycleAnalytics::ReviewEvent do
|
||||||
it_behaves_like 'default query config'
|
it_behaves_like 'default query config' 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
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue