summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-27 11:45:53 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-27 11:45:53 +0000
commit2cd1cee639843fed70bdd1be27c147bb6a719877 (patch)
treea2534640e7364d45f8ff0303a4ea207a26c11cd1
parent464123b388677bb2214515c9a495bd453689ff59 (diff)
parenta9e2686139fa4c7d5cd5f567854dc95627cc26a7 (diff)
downloadgitlab-ce-2cd1cee639843fed70bdd1be27c147bb6a719877.tar.gz
Merge branch 'commit-graphs-by-email' into 'master'
Group project contributions by both name and email. See https://twitter.com/Argorain/status/598751646143897600. We now group by both name and email, so that "Douwe Maan - douwe@gitlab.com", "Douwe Maan - me@douwe.me" and "Douwe M. - me@douwe.me" are all combined into one graph. Fixes internal issue https://dev.gitlab.org/gitlab/gitlabhq/issues/2328. See merge request !700
-rw-r--r--CHANGELOG1
-rw-r--r--app/assets/javascripts/stat_graph_contributors_util.js.coffee20
-rw-r--r--spec/javascripts/stat_graph_contributors_util_spec.js8
3 files changed, 19 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ee733858552..8f77dd6561c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -20,6 +20,7 @@ v 7.12.0 (unreleased)
- Consistently refer to MRs as either Accepted or Rejected.
- Add Accepted and Rejected tabs to MR lists.
- Prefix EmailsOnPush email subject with `[Git]`.
+ - Group project contributions by both name and email.
v 7.11.2
- no changes
diff --git a/app/assets/javascripts/stat_graph_contributors_util.js.coffee b/app/assets/javascripts/stat_graph_contributors_util.js.coffee
index 1670f5c7bc1..cfe5508290f 100644
--- a/app/assets/javascripts/stat_graph_contributors_util.js.coffee
+++ b/app/assets/javascripts/stat_graph_contributors_util.js.coffee
@@ -2,11 +2,15 @@ window.ContributorsStatGraphUtil =
parse_log: (log) ->
total = {}
by_author = {}
+ by_email = {}
for entry in log
@add_date(entry.date, total) unless total[entry.date]?
- @add_author(entry, by_author) unless by_author[entry.author_name]?
- @add_date(entry.date, by_author[entry.author_name]) unless by_author[entry.author_name][entry.date]
- @store_data(entry, total[entry.date], by_author[entry.author_name][entry.date])
+
+ data = by_author[entry.author_name] #|| by_email[entry.author_email]
+ data ?= @add_author(entry, by_author, by_email)
+
+ @add_date(entry.date, data) unless data[entry.date]
+ @store_data(entry, total[entry.date], data[entry.date])
total = _.toArray(total)
by_author = _.toArray(by_author)
total: total, by_author: by_author
@@ -15,10 +19,12 @@ window.ContributorsStatGraphUtil =
collection[date] = {}
collection[date].date = date
- add_author: (author, by_author) ->
- by_author[author.author_name] = {}
- by_author[author.author_name].author_name = author.author_name
- by_author[author.author_name].author_email = author.author_email
+ add_author: (author, by_author, by_email) ->
+ data = {}
+ data.author_name = author.author_name
+ data.author_email = author.author_email
+ by_author[author.author_name] = data
+ by_email[author.author_email] = data
store_data: (entry, total, by_author) ->
@store_commits(total, by_author)
diff --git a/spec/javascripts/stat_graph_contributors_util_spec.js b/spec/javascripts/stat_graph_contributors_util_spec.js
index ee90892eb48..dbafe782b77 100644
--- a/spec/javascripts/stat_graph_contributors_util_spec.js
+++ b/spec/javascripts/stat_graph_contributors_util_spec.js
@@ -118,9 +118,11 @@ describe("ContributorsStatGraphUtil", function () {
describe("#add_author", function () {
it("adds an author field to the collection", function () {
var fake_author = { author_name: "Author", author_email: 'fake@email.com' }
- var fake_collection = {}
- ContributorsStatGraphUtil.add_author(fake_author, fake_collection)
- expect(fake_collection[fake_author.author_name].author_name).toEqual("Author")
+ var fake_author_collection = {}
+ var fake_email_collection = {}
+ ContributorsStatGraphUtil.add_author(fake_author, fake_author_collection, fake_email_collection)
+ expect(fake_author_collection[fake_author.author_name].author_name).toEqual("Author")
+ expect(fake_email_collection[fake_author.author_email].author_name).toEqual("Author")
})
})