summaryrefslogtreecommitdiff
path: root/lib/gitlab
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-16 09:58:23 +0100
committerJames Lopez <james@jameslopez.es>2016-11-17 08:22:59 +0100
commitcbc9f0cd1aa9f379952b6e4d3ad6df9971f9092a (patch)
treec8f1cfd9bab5183825a46ddd8a978d261b26cfec /lib/gitlab
parent633ddc9ed98c690c082c7347422ac85f9b592fb4 (diff)
downloadgitlab-ce-cbc9f0cd1aa9f379952b6e4d3ad6df9971f9092a.tar.gz
fix issue with commits and also updated routes
Diffstat (limited to 'lib/gitlab')
-rw-r--r--lib/gitlab/cycle_analytics/events.rb18
-rw-r--r--lib/gitlab/cycle_analytics/query_config.rb3
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/gitlab/cycle_analytics/events.rb b/lib/gitlab/cycle_analytics/events.rb
index d3c7d6fe1aa..f4d6d2049ef 100644
--- a/lib/gitlab/cycle_analytics/events.rb
+++ b/lib/gitlab/cycle_analytics/events.rb
@@ -12,9 +12,11 @@ module Gitlab
def plan_events
@fetcher.fetch(stage: :plan).map do |event|
- commit = first_time_reference_commit(event.delete('commits'), event)
+ st_commit = first_time_reference_commit(event.delete('commits'), event)
- AnalyticsCommitSerializer.new(project: @project, total_time: event['total_time']).represent(commit).as_json
+ next unless st_commit
+
+ serialize_commit(event, st_commit)
end
end
@@ -53,11 +55,17 @@ module Gitlab
end
def first_time_reference_commit(commits, event)
- st_commit = YAML.load(commits).detect do |commit|
- commit['created_at'] == event['first_mentioned_in_commit_at']
+ YAML.load(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_i
end
+ end
+
+ def serialize_commit(event, st_commit)
+ commit = Commit.new(Gitlab::Git::Commit.new(st_commit), @project)
- Commit.new(Gitlab::Git::Commit.new(st_commit), @project)
+ AnalyticsCommitSerializer.new(project: @project, total_time: event['total_time']).represent(commit).as_json
end
def interval_in_words(diff)
diff --git a/lib/gitlab/cycle_analytics/query_config.rb b/lib/gitlab/cycle_analytics/query_config.rb
index a18c263ba53..4fddbad95f2 100644
--- a/lib/gitlab/cycle_analytics/query_config.rb
+++ b/lib/gitlab/cycle_analytics/query_config.rb
@@ -33,7 +33,8 @@ module Gitlab
start_time_attrs: issue_metrics_table[:first_associated_with_milestone_at],
end_time_attrs: [issue_metrics_table[:first_added_to_board_at],
issue_metrics_table[:first_mentioned_in_commit_at]],
- projections: [mr_diff_table[:st_commits].as('commits')]
+ projections: [mr_diff_table[:st_commits].as('commits'),
+ issue_metrics_table[:first_mentioned_in_commit_at]]
}
end