added production events and related spec
This commit is contained in:
parent
275292de47
commit
3cdc9af78e
3 changed files with 44 additions and 11 deletions
|
@ -10,9 +10,9 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: backend pagination - specially for commits, etc...
|
# TODO: backend pagination - specially for commits, etc...
|
||||||
|
# TODO figure out what the frontend needs for displaying the avatar
|
||||||
|
|
||||||
def issue_events
|
def issue_events
|
||||||
# TODO figure out what the frontend needs for displaying the avatar
|
|
||||||
@fetcher.fetch(stage: :issue).each { |event| parse_event(event) }
|
@fetcher.fetch(stage: :issue).each { |event| parse_event(event) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,6 +46,10 @@ module Gitlab
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def production_events
|
||||||
|
@fetcher.fetch(stage: :production).each { |event| parse_event(event) }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def parse_event(event)
|
def parse_event(event)
|
||||||
|
|
|
@ -8,9 +8,7 @@ module Gitlab
|
||||||
start_time_attrs: issue_table[:created_at],
|
start_time_attrs: issue_table[:created_at],
|
||||||
end_time_attrs: [issue_metrics_table[:first_associated_with_milestone_at],
|
end_time_attrs: [issue_metrics_table[:first_associated_with_milestone_at],
|
||||||
issue_metrics_table[:first_added_to_board_at]],
|
issue_metrics_table[:first_added_to_board_at]],
|
||||||
projections: [issue_table[:title], issue_table[:iid], issue_table[:created_at], user_table[:name]],
|
projections: [issue_table[:title], issue_table[:iid], issue_table[:created_at], user_table[:name]]
|
||||||
project: @project,
|
|
||||||
from: @from
|
|
||||||
},
|
},
|
||||||
plan: {
|
plan: {
|
||||||
start_time_attrs: issue_metrics_table[:first_associated_with_milestone_at],
|
start_time_attrs: issue_metrics_table[:first_associated_with_milestone_at],
|
||||||
|
@ -39,12 +37,15 @@ module Gitlab
|
||||||
start_time_attrs: mr_metrics_table[:merged_at],
|
start_time_attrs: mr_metrics_table[:merged_at],
|
||||||
end_time_attrs: mr_metrics_table[:first_deployed_to_production_at],
|
end_time_attrs: mr_metrics_table[:first_deployed_to_production_at],
|
||||||
projections: mr_metrics_table[:ci_commit_id]
|
projections: mr_metrics_table[:ci_commit_id]
|
||||||
}
|
},
|
||||||
|
production: {
|
||||||
|
start_time_attrs: issue_table[:created_at],
|
||||||
|
end_time_attrs: mr_metrics_table[:first_deployed_to_production_at],
|
||||||
|
projections: [issue_table[:title], issue_table[:iid], issue_table[:created_at], user_table[:name]]
|
||||||
|
},
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
def initialize(project:, from:)
|
def initialize(project:, from:)
|
||||||
@project = project
|
|
||||||
@from = from
|
|
||||||
@query = EventsQuery.new(project: project, from: from)
|
@query = EventsQuery.new(project: project, from: from)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,14 +61,13 @@ module Gitlab
|
||||||
base_query.join(user_table).on(issue_table[:author_id].eq(user_table[:id]))
|
base_query.join(user_table).on(issue_table[:author_id].eq(user_table[:id]))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias_method :code_custom_query, :issue_custom_query
|
||||||
|
alias_method :production_custom_query, :issue_custom_query
|
||||||
|
|
||||||
def plan_custom_query(base_query)
|
def plan_custom_query(base_query)
|
||||||
base_query.join(mr_diff_table).on(mr_diff_table[:merge_request_id].eq(mr_table[:id]))
|
base_query.join(mr_diff_table).on(mr_diff_table[:merge_request_id].eq(mr_table[:id]))
|
||||||
end
|
end
|
||||||
|
|
||||||
def code_custom_query(base_query)
|
|
||||||
base_query.join(user_table).on(issue_table[:author_id].eq(user_table[:id]))
|
|
||||||
end
|
|
||||||
|
|
||||||
def review_custom_query(base_query)
|
def review_custom_query(base_query)
|
||||||
base_query.join(user_table).on(mr_table[:author_id].eq(user_table[:id]))
|
base_query.join(user_table).on(mr_table[:author_id].eq(user_table[:id]))
|
||||||
end
|
end
|
||||||
|
|
|
@ -149,6 +149,35 @@ describe Gitlab::CycleAnalytics::Events do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#production_events' do
|
||||||
|
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
merge_merge_requests_closing_issue(context)
|
||||||
|
deploy_master
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has the total time' do
|
||||||
|
expect(subject.production_events.first['total_time']).to eq('2 days')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has a title' do
|
||||||
|
expect(subject.production_events.first['title']).to eq(context.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has an iid' do
|
||||||
|
expect(subject.production_events.first['iid']).to eq(context.iid.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has a created_at timestamp' do
|
||||||
|
expect(subject.production_events.first['created_at']).to end_with('ago')
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has the author's name" do
|
||||||
|
expect(subject.production_events.first['name']).to eq(context.author.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def setup(context)
|
def setup(context)
|
||||||
milestone = create(:milestone, project: project)
|
milestone = create(:milestone, project: project)
|
||||||
context.update(milestone: milestone)
|
context.update(milestone: milestone)
|
||||||
|
|
Loading…
Reference in a new issue