Commit 31e9f82ebc24ff04cb4eeaf933f6f3b158a38a62

Authored by Dmitriy Zaporozhets
1 parent 7825830c

Improve repository graph

app/assets/javascripts/stat_graph_contributors.js.coffee
@@ -16,7 +16,7 @@ class window.ContributorsStatGraph @@ -16,7 +16,7 @@ class window.ContributorsStatGraph
16 _.each(limited_author_data, (d) => 16 _.each(limited_author_data, (d) =>
17 author_header = @create_author_header(d) 17 author_header = @create_author_header(d)
18 $(".contributors-list").append(author_header) 18 $(".contributors-list").append(author_header)
19 - @authors[d.author] = author_graph = new ContributorsAuthorGraph(d.dates) 19 + @authors[d.author_name] = author_graph = new ContributorsAuthorGraph(d.dates)
20 author_graph.draw() 20 author_graph.draw()
21 ) 21 )
22 format_author_commit_info: (author) -> 22 format_author_commit_info: (author) ->
@@ -46,13 +46,15 @@ class window.ContributorsStatGraph @@ -46,13 +46,15 @@ class window.ContributorsStatGraph
46 class: 'person' 46 class: 'person'
47 style: 'display: block;' 47 style: 'display: block;'
48 }) 48 })
49 - author_name = $('<h4>' + author.author + '</h4>') 49 + author_name = $('<h4>' + author.author_name + '</h4>')
  50 + author_email = $('<p class="graph-author-email">' + author.author_email + '</p>')
50 author_commit_info_span = $('<span/>', { 51 author_commit_info_span = $('<span/>', {
51 class: 'commits' 52 class: 'commits'
52 }) 53 })
53 author_commit_info = @format_author_commit_info(author) 54 author_commit_info = @format_author_commit_info(author)
54 author_commit_info_span.html(author_commit_info) 55 author_commit_info_span.html(author_commit_info)
55 list_item.append(author_name) 56 list_item.append(author_name)
  57 + list_item.append(author_email)
56 list_item.append(author_commit_info_span) 58 list_item.append(author_commit_info_span)
57 list_item 59 list_item
58 redraw_master: -> 60 redraw_master: ->
@@ -65,9 +67,9 @@ class window.ContributorsStatGraph @@ -65,9 +67,9 @@ class window.ContributorsStatGraph
65 author_commits = ContributorsStatGraphUtil.get_author_data(@parsed_log, @field, x_domain) 67 author_commits = ContributorsStatGraphUtil.get_author_data(@parsed_log, @field, x_domain)
66 _.each(author_commits, (d) => 68 _.each(author_commits, (d) =>
67 @redraw_author_commit_info(d) 69 @redraw_author_commit_info(d)
68 - $(@authors[d.author].list_item).appendTo("ol")  
69 - @authors[d.author].set_data(d.dates)  
70 - @authors[d.author].redraw() 70 + $(@authors[d.author_name].list_item).appendTo("ol")
  71 + @authors[d.author_name].set_data(d.dates)
  72 + @authors[d.author_name].redraw()
71 ) 73 )
72 set_current_field: (field) -> 74 set_current_field: (field) ->
73 @field = field 75 @field = field
@@ -77,6 +79,6 @@ class window.ContributorsStatGraph @@ -77,6 +79,6 @@ class window.ContributorsStatGraph
77 print = print_date_format(x_domain[0]) + " - " + print_date_format(x_domain[1]) 79 print = print_date_format(x_domain[0]) + " - " + print_date_format(x_domain[1])
78 $("#date_header").text(print) 80 $("#date_header").text(print)
79 redraw_author_commit_info: (author) -> 81 redraw_author_commit_info: (author) ->
80 - author_list_item = $(@authors[author.author].list_item) 82 + author_list_item = $(@authors[author.author_name].list_item)
81 author_commit_info = @format_author_commit_info(author) 83 author_commit_info = @format_author_commit_info(author)
82 author_list_item.find("span").html(author_commit_info) 84 author_list_item.find("span").html(author_commit_info)
app/assets/javascripts/stat_graph_contributors_graph.js.coffee
@@ -90,9 +90,9 @@ class window.ContributorsMasterGraph extends ContributorsGraph @@ -90,9 +90,9 @@ class window.ContributorsMasterGraph extends ContributorsGraph
90 y(d.commits = d.commits ? d.additions ? d.deletions) 90 y(d.commits = d.commits ? d.additions ? d.deletions)
91 ).interpolate("basis") 91 ).interpolate("basis")
92 create_brush: -> 92 create_brush: ->
93 - @brush = d3.svg.brush().x(@x).on("brushend", @update_content); 93 + @brush = d3.svg.brush().x(@x).on("brushend", @update_content)
94 draw_path: (data) -> 94 draw_path: (data) ->
95 - @svg.append("path").datum(data).attr("class", "area").attr("d", @area); 95 + @svg.append("path").datum(data).attr("class", "area").attr("d", @area)
96 add_brush: -> 96 add_brush: ->
97 @svg.append("g").attr("class", "selection").call(@brush).selectAll("rect").attr("height", @height); 97 @svg.append("g").attr("class", "selection").call(@brush).selectAll("rect").attr("height", @height);
98 update_content: => 98 update_content: =>
app/assets/javascripts/stat_graph_contributors_util.js.coffee
@@ -4,9 +4,9 @@ window.ContributorsStatGraphUtil = @@ -4,9 +4,9 @@ window.ContributorsStatGraphUtil =
4 by_author = {} 4 by_author = {}
5 for entry in log 5 for entry in log
6 @add_date(entry.date, total) unless total[entry.date]? 6 @add_date(entry.date, total) unless total[entry.date]?
7 - @add_author(entry.author, by_author) unless by_author[entry.author]?  
8 - @add_date(entry.date, by_author[entry.author]) unless by_author[entry.author][entry.date]  
9 - @store_data(entry, total[entry.date], by_author[entry.author][entry.date]) 7 + @add_author(entry, by_author) unless by_author[entry.author_name]?
  8 + @add_date(entry.date, by_author[entry.author_name]) unless by_author[entry.author_name][entry.date]
  9 + @store_data(entry, total[entry.date], by_author[entry.author_name][entry.date])
10 total = _.toArray(total) 10 total = _.toArray(total)
11 by_author = _.toArray(by_author) 11 by_author = _.toArray(by_author)
12 total: total, by_author: by_author 12 total: total, by_author: by_author
@@ -16,8 +16,9 @@ window.ContributorsStatGraphUtil = @@ -16,8 +16,9 @@ window.ContributorsStatGraphUtil =
16 collection[date].date = date 16 collection[date].date = date
17 17
18 add_author: (author, by_author) -> 18 add_author: (author, by_author) ->
19 - by_author[author] = {}  
20 - by_author[author].author = author 19 + by_author[author.author_name] = {}
  20 + by_author[author.author_name].author_name = author.author_name
  21 + by_author[author.author_name].author_email = author.author_email
21 22
22 store_data: (entry, total, by_author) -> 23 store_data: (entry, total, by_author) ->
23 @store_commits(total, by_author) 24 @store_commits(total, by_author)
@@ -71,10 +72,11 @@ window.ContributorsStatGraphUtil = @@ -71,10 +72,11 @@ window.ContributorsStatGraphUtil =
71 72
72 parse_log_entry: (log_entry, field, date_range) -> 73 parse_log_entry: (log_entry, field, date_range) ->
73 parsed_entry = {} 74 parsed_entry = {}
74 - parsed_entry.author = log_entry.author 75 + parsed_entry.author_name = log_entry.author_name
  76 + parsed_entry.author_email = log_entry.author_email
75 parsed_entry.dates = {} 77 parsed_entry.dates = {}
76 parsed_entry.commits = parsed_entry.additions = parsed_entry.deletions = 0 78 parsed_entry.commits = parsed_entry.additions = parsed_entry.deletions = 0
77 - _.each(_.omit(log_entry, 'author'), (value, key) => 79 + _.each(_.omit(log_entry, 'author_name', 'author_email'), (value, key) =>
78 if @in_range(value.date, date_range) 80 if @in_range(value.date, date_range)
79 parsed_entry.dates[value.date] = value[field] 81 parsed_entry.dates[value.date] = value[field]
80 parsed_entry.commits += value.commits 82 parsed_entry.commits += value.commits
@@ -88,4 +90,4 @@ window.ContributorsStatGraphUtil = @@ -88,4 +90,4 @@ window.ContributorsStatGraphUtil =
88 true 90 true
89 else 91 else
90 false 92 false
91 -  
92 \ No newline at end of file 93 \ No newline at end of file
  94 +
app/assets/stylesheets/sections/graph.scss
@@ -22,6 +22,11 @@ @@ -22,6 +22,11 @@
22 .graph-author-commits-count { 22 .graph-author-commits-count {
23 } 23 }
24 24
  25 + .graph-author-email {
  26 + float: right;
  27 + color: #777;
  28 + }
  29 +
25 .graph-additions { 30 .graph-additions {
26 color: #4a2; 31 color: #4a2;
27 } 32 }
app/views/projects/graphs/show.html.haml
1 .loading-graph 1 .loading-graph
2 %center 2 %center
3 .loading 3 .loading
4 - %h3.page-title Building repository graph. Please wait a moment. 4 + %h3.page-title Building repository graph.
  5 + %p Please wait a moment, this page will automatically refresh when ready.
5 6
6 .stat-graph 7 .stat-graph
7 .header.clearfix 8 .header.clearfix
@@ -11,6 +12,8 @@ @@ -11,6 +12,8 @@
11 %option{:value => "additions"} Additions 12 %option{:value => "additions"} Additions
12 %option{:value => "deletions"} Deletions 13 %option{:value => "deletions"} Deletions
13 %h3#date_header.page-title 14 %h3#date_header.page-title
  15 + %p.light
  16 + Commits to #{@project.default_branch}, excluding merge commits. Limited by 8,000 commits
14 %input#brush_change{:type => "hidden"} 17 %input#brush_change{:type => "hidden"}
15 .graphs 18 .graphs
16 #contributors-master 19 #contributors-master