From 2fa5c7513e77ecf990cdcf2d4fe7ecad82d8d7c9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 25 May 2015 15:43:22 +0200 Subject: Group project contributions by both name and email. --- CHANGELOG | 1 + .../stat_graph_contributors_util.js.coffee | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9e4033fcc3d..f4f1c7603df 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ v 7.12.0 (unreleased) - Update Asciidoctor gem to version 1.5.2. (Jakub Jirutka) - Fix resolving of relative links to repository files in AsciiDoc documents. (Jakub Jirutka) - Use the user list from the target project in a merge request (Stan Hu) + - 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) -- cgit v1.2.1 From a9e2686139fa4c7d5cd5f567854dc95627cc26a7 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 25 May 2015 16:31:20 +0200 Subject: Update specs. --- spec/javascripts/stat_graph_contributors_util_spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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") }) }) -- cgit v1.2.1