85be6d83be
* upstream/master: (170 commits) support ordering of project notes in notes api Redirect to an already forked project if it exists Reschedule the migration to populate fork networks Create fork networks for forks for which the source was deleted. Fix item name and namespace text overflow in Projects dropdown Minor backport from EE fix link that was linking to `html` instead of `md` Backport epic tasklist Add timeouts for Gitaly calls SSHUploadPack over Gitaly is now OptOut fix icon colors in commit list Fix star icon color/stroke Backport border inline edit Add checkboxes to automatically run AutoDevops pipeline BE for automatic pipeline when enabling Auto DevOps I am certainly weary of debugging sidekiq but I don't think that's what was meant Ensure MRs always use branch refs for comparison Fix issue comment submit button disabled on GFM paste Lock seed-fu at the correct version in Gemfile.lock Improve indexes on merge_request_diffs ...
61 lines
1.6 KiB
Ruby
61 lines
1.6 KiB
Ruby
module Gitlab
|
|
module CycleAnalytics
|
|
class PlanEventFetcher < BaseEventFetcher
|
|
def initialize(*args)
|
|
@projections = [mr_diff_table[:id],
|
|
issue_metrics_table[:first_mentioned_in_commit_at]]
|
|
|
|
super(*args)
|
|
end
|
|
|
|
def events_query
|
|
base_query
|
|
.join(mr_diff_table)
|
|
.on(mr_diff_table[:merge_request_id].eq(mr_table[:id]))
|
|
|
|
super
|
|
end
|
|
|
|
private
|
|
|
|
def allowed_ids
|
|
nil
|
|
end
|
|
|
|
def merge_request_diff_commits
|
|
@merge_request_diff_commits ||=
|
|
MergeRequestDiffCommit
|
|
.where(merge_request_diff_id: event_result.map { |event| event['id'] })
|
|
.group_by(&:merge_request_diff_id)
|
|
end
|
|
|
|
def serialize(event)
|
|
commit = first_time_reference_commit(event)
|
|
|
|
return unless commit
|
|
|
|
serialize_commit(event, commit, query)
|
|
end
|
|
|
|
def first_time_reference_commit(event)
|
|
return nil unless event && merge_request_diff_commits
|
|
|
|
commits = merge_request_diff_commits[event['id'].to_i]
|
|
|
|
return nil if commits.blank?
|
|
|
|
commits.find do |commit|
|
|
next unless commit[:committed_date] && event['first_mentioned_in_commit_at']
|
|
|
|
commit[:committed_date].to_i == DateTime.parse(event['first_mentioned_in_commit_at'].to_s).to_i
|
|
end
|
|
end
|
|
|
|
def serialize_commit(event, commit, query)
|
|
commit = Commit.from_hash(commit.to_hash, @project)
|
|
|
|
AnalyticsCommitSerializer.new(project: @project, total_time: event['total_time']).represent(commit)
|
|
end
|
|
end
|
|
end
|
|
end
|