refactor events

This commit is contained in:
James Lopez 2016-11-18 10:13:42 +01:00
parent e56c305be0
commit cd222357ad
3 changed files with 12 additions and 26 deletions

View file

@ -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

View file

@ -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

View file

@ -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