Commit 038d40f0f5b202fe9ed133fdf9de1774bdbc8ede
1 parent
9e2c8d94
Exists in
master
and in
4 other branches
Solve inconsistency between network graph & stat graphs
Showing
21 changed files
with
173 additions
and
167 deletions
Show diff stats
app/controllers/graph_controller.rb
| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | -class GraphController < ProjectResourceController | |
| 2 | - include ExtractsPath | |
| 3 | - include ApplicationHelper | |
| 4 | - | |
| 5 | - # Authorize | |
| 6 | - before_filter :authorize_read_project! | |
| 7 | - before_filter :authorize_code_access! | |
| 8 | - before_filter :require_non_empty_project | |
| 9 | - | |
| 10 | - def show | |
| 11 | - if @options[:q] | |
| 12 | - @commit = @project.repository.commit(@options[:q]) || @commit | |
| 13 | - end | |
| 14 | - | |
| 15 | - respond_to do |format| | |
| 16 | - format.html | |
| 17 | - | |
| 18 | - format.json do | |
| 19 | - @graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref]) | |
| 20 | - end | |
| 21 | - end | |
| 22 | - end | |
| 23 | -end |
| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | +class GraphsController < ProjectResourceController | |
| 2 | + # Authorize | |
| 3 | + before_filter :authorize_read_project! | |
| 4 | + before_filter :authorize_code_access! | |
| 5 | + before_filter :require_non_empty_project | |
| 6 | + | |
| 7 | + def show | |
| 8 | + respond_to do |format| | |
| 9 | + format.html | |
| 10 | + format.js do | |
| 11 | + @repo = @project.repository | |
| 12 | + @stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref) | |
| 13 | + @log = @stats.parsed_log.to_json | |
| 14 | + end | |
| 15 | + end | |
| 16 | + end | |
| 17 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | +class NetworkController < ProjectResourceController | |
| 2 | + include ExtractsPath | |
| 3 | + include ApplicationHelper | |
| 4 | + | |
| 5 | + # Authorize | |
| 6 | + before_filter :authorize_read_project! | |
| 7 | + before_filter :authorize_code_access! | |
| 8 | + before_filter :require_non_empty_project | |
| 9 | + | |
| 10 | + def show | |
| 11 | + if @options[:q] | |
| 12 | + @commit = @project.repository.commit(@options[:q]) || @commit | |
| 13 | + end | |
| 14 | + | |
| 15 | + respond_to do |format| | |
| 16 | + format.html | |
| 17 | + | |
| 18 | + format.json do | |
| 19 | + @graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref]) | |
| 20 | + end | |
| 21 | + end | |
| 22 | + end | |
| 23 | +end | ... | ... |
app/controllers/refs_controller.rb
| ... | ... | @@ -14,7 +14,7 @@ class RefsController < ProjectResourceController |
| 14 | 14 | elsif params[:destination] == "blob" |
| 15 | 15 | project_blob_path(@project, (@id)) |
| 16 | 16 | elsif params[:destination] == "graph" |
| 17 | - project_graph_path(@project, @id, @options) | |
| 17 | + project_network_path(@project, @id, @options) | |
| 18 | 18 | else |
| 19 | 19 | project_commits_path(@project, @id) |
| 20 | 20 | end | ... | ... |
app/controllers/stat_graph_controller.rb
| ... | ... | @@ -1,17 +0,0 @@ |
| 1 | -class StatGraphController < ProjectResourceController | |
| 2 | - # Authorize | |
| 3 | - before_filter :authorize_read_project! | |
| 4 | - before_filter :authorize_code_access! | |
| 5 | - before_filter :require_non_empty_project | |
| 6 | - | |
| 7 | - def show | |
| 8 | - respond_to do |format| | |
| 9 | - format.html | |
| 10 | - format.js do | |
| 11 | - @repo = @project.repository | |
| 12 | - @stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref) | |
| 13 | - @log = @stats.parsed_log.to_json | |
| 14 | - end | |
| 15 | - end | |
| 16 | - end | |
| 17 | -end |
app/views/graph/_head.html.haml
| ... | ... | @@ -1,26 +0,0 @@ |
| 1 | -%h3.page_title Project Network Graph | |
| 2 | -%hr | |
| 3 | - | |
| 4 | -.clearfix | |
| 5 | - .pull-left | |
| 6 | - = render partial: 'shared/ref_switcher', locals: {destination: 'graph'} | |
| 7 | - .pull-left | |
| 8 | - = form_tag project_graph_path(@project, @id), method: :get do |f| | |
| 9 | - .control-group | |
| 10 | - = label_tag :filter_ref, "Show only selected ref", class: 'control-label light' | |
| 11 | - .controls | |
| 12 | - = check_box_tag :filter_ref, 1, @options[:filter_ref] | |
| 13 | - - @options.each do |key, value| | |
| 14 | - = hidden_field_tag(key, value, id: nil) unless key == "filter_ref" | |
| 15 | - | |
| 16 | - .search.pull-right | |
| 17 | - = form_tag project_graph_path(@project, @id), method: :get do |f| | |
| 18 | - .control-group | |
| 19 | - = label_tag :search , "Looking for commit:", class: 'control-label light' | |
| 20 | - .controls | |
| 21 | - = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input xlarge" | |
| 22 | - = button_tag type: 'submit', class: 'btn vtop' do | |
| 23 | - %i.icon-search | |
| 24 | - - @options.each do |key, value| | |
| 25 | - = hidden_field_tag(key, value, id: nil) unless key == "q" | |
| 26 | - |
app/views/graph/show.html.haml
| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | -= render "head" | |
| 2 | -.graph_holder | |
| 3 | - %h4 | |
| 4 | - %small You can move around the graph by using the arrow keys. | |
| 5 | - #holder.graph | |
| 6 | - .loading.loading-gray | |
| 7 | - | |
| 8 | -:javascript | |
| 9 | - var branch_graph; | |
| 10 | - $("#filter_ref").click(function() { | |
| 11 | - $(this).closest('form').submit(); | |
| 12 | - }); | |
| 13 | - branch_graph = new BranchGraph($("#holder"), { | |
| 14 | - url: '#{project_graph_path(@project, @ref, @options.merge(format: :json))}', | |
| 15 | - commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', | |
| 16 | - ref: '#{@ref}', | |
| 17 | - commit_id: '#{@commit.id}' | |
| 18 | - }); |
app/views/graph/show.json.erb
| ... | ... | @@ -1,23 +0,0 @@ |
| 1 | -<% self.formats = ["html"] %> | |
| 2 | - | |
| 3 | -<%= raw( | |
| 4 | - { | |
| 5 | - days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] }, | |
| 6 | - commits: @graph.commits.map do |c| | |
| 7 | - { | |
| 8 | - parents: parents_zip_spaces(c.parents(@graph.map), c.parent_spaces), | |
| 9 | - author: { | |
| 10 | - name: c.author_name, | |
| 11 | - email: c.author_email, | |
| 12 | - icon: gravatar_icon(c.author_email, 20) | |
| 13 | - }, | |
| 14 | - time: c.time, | |
| 15 | - space: c.spaces.first, | |
| 16 | - refs: get_refs(c), | |
| 17 | - id: c.sha, | |
| 18 | - date: c.date, | |
| 19 | - message: c.message, | |
| 20 | - } | |
| 21 | - end | |
| 22 | - }.to_json | |
| 23 | -) %> |
| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | +.loading-graph | |
| 2 | + %center | |
| 3 | + .loading | |
| 4 | + %h3.page_title Building repository graph. Please wait a moment. | |
| 5 | + | |
| 6 | +.stat-graph | |
| 7 | + .header.clearfix | |
| 8 | + .pull-right | |
| 9 | + %select | |
| 10 | + %option{:value => "commits"} Commits | |
| 11 | + %option{:value => "additions"} Additions | |
| 12 | + %option{:value => "deletions"} Deletions | |
| 13 | + %h3#date_header.page_title | |
| 14 | + %input#brush_change{:type => "hidden"} | |
| 15 | + .graphs | |
| 16 | + #contributors-master | |
| 17 | + #contributors.clearfix | |
| 18 | + %ol.contributors-list.clearfix | |
| 19 | + | |
| 20 | +:javascript | |
| 21 | + $(".stat-graph").hide(); | |
| 22 | + | |
| 23 | + $.ajax({ | |
| 24 | + type: "GET", | |
| 25 | + url: location.href, | |
| 26 | + complete: function() { | |
| 27 | + $(".loading-graph").hide(); | |
| 28 | + $(".stat-graph").show(); | |
| 29 | + }, | |
| 30 | + dataType: "script" | |
| 31 | + }); | ... | ... |
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +:plain | |
| 2 | + controller = new ContributorsStatGraph | |
| 3 | + controller.init(#{@log}) | |
| 4 | + | |
| 5 | + $("select").change( function () { | |
| 6 | + var field = $(this).val() | |
| 7 | + controller.set_current_field(field) | |
| 8 | + controller.redraw_master() | |
| 9 | + controller.redraw_authors() | |
| 10 | + }) | |
| 11 | + | |
| 12 | + $("#brush_change").change( function () { | |
| 13 | + controller.change_date_header() | |
| 14 | + controller.redraw_authors() | |
| 15 | + }) | |
| 16 | + | ... | ... |
app/views/layouts/nav/_project.html.haml
| ... | ... | @@ -9,10 +9,10 @@ |
| 9 | 9 | = link_to 'Files', project_tree_path(@project, @ref || @repository.root_ref) |
| 10 | 10 | = nav_link(controller: %w(commit commits compare repositories protected_branches)) do |
| 11 | 11 | = link_to "Commits", project_commits_path(@project, @ref || @repository.root_ref) |
| 12 | - = nav_link(controller: %w(graph)) do | |
| 13 | - = link_to "Network", project_graph_path(@project, @ref || @repository.root_ref) | |
| 14 | - = nav_link(controller: %w(stat_graph)) do | |
| 15 | - = link_to "Graphs", project_stat_graph_path(@project, @ref || @repository.root_ref) | |
| 12 | + = nav_link(controller: %w(network)) do | |
| 13 | + = link_to "Network", project_network_path(@project, @ref || @repository.root_ref) | |
| 14 | + = nav_link(controller: %w(graphs)) do | |
| 15 | + = link_to "Graphs", project_graph_path(@project, @ref || @repository.root_ref) | |
| 16 | 16 | |
| 17 | 17 | - if @project.issues_enabled |
| 18 | 18 | = nav_link(controller: %w(issues milestones labels)) do | ... | ... |
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +%h3.page_title Project Network Graph | |
| 2 | +%hr | |
| 3 | + | |
| 4 | +.clearfix | |
| 5 | + .pull-left | |
| 6 | + = render partial: 'shared/ref_switcher', locals: {destination: 'graph'} | |
| 7 | + .pull-left | |
| 8 | + = form_tag project_network_path(@project, @id), method: :get do |f| | |
| 9 | + .control-group | |
| 10 | + = label_tag :filter_ref, "Show only selected ref", class: 'control-label light' | |
| 11 | + .controls | |
| 12 | + = check_box_tag :filter_ref, 1, @options[:filter_ref] | |
| 13 | + - @options.each do |key, value| | |
| 14 | + = hidden_field_tag(key, value, id: nil) unless key == "filter_ref" | |
| 15 | + | |
| 16 | + .search.pull-right | |
| 17 | + = form_tag project_network_path(@project, @id), method: :get do |f| | |
| 18 | + .control-group | |
| 19 | + = label_tag :search , "Looking for commit:", class: 'control-label light' | |
| 20 | + .controls | |
| 21 | + = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input xlarge" | |
| 22 | + = button_tag type: 'submit', class: 'btn vtop' do | |
| 23 | + %i.icon-search | |
| 24 | + - @options.each do |key, value| | |
| 25 | + = hidden_field_tag(key, value, id: nil) unless key == "q" | |
| 26 | + | ... | ... |
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | += render "head" | |
| 2 | +.graph_holder | |
| 3 | + %h4 | |
| 4 | + %small You can move around the graph by using the arrow keys. | |
| 5 | + #holder.graph | |
| 6 | + .loading.loading-gray | |
| 7 | + | |
| 8 | +:javascript | |
| 9 | + var branch_graph; | |
| 10 | + $("#filter_ref").click(function() { | |
| 11 | + $(this).closest('form').submit(); | |
| 12 | + }); | |
| 13 | + branch_graph = new BranchGraph($("#holder"), { | |
| 14 | + url: '#{project_network_path(@project, @ref, @options.merge(format: :json))}', | |
| 15 | + commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}', | |
| 16 | + ref: '#{@ref}', | |
| 17 | + commit_id: '#{@commit.id}' | |
| 18 | + }); | ... | ... |
| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | +<% self.formats = ["html"] %> | |
| 2 | + | |
| 3 | +<%= raw( | |
| 4 | + { | |
| 5 | + days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] }, | |
| 6 | + commits: @graph.commits.map do |c| | |
| 7 | + { | |
| 8 | + parents: parents_zip_spaces(c.parents(@graph.map), c.parent_spaces), | |
| 9 | + author: { | |
| 10 | + name: c.author_name, | |
| 11 | + email: c.author_email, | |
| 12 | + icon: gravatar_icon(c.author_email, 20) | |
| 13 | + }, | |
| 14 | + time: c.time, | |
| 15 | + space: c.spaces.first, | |
| 16 | + refs: get_refs(c), | |
| 17 | + id: c.sha, | |
| 18 | + date: c.date, | |
| 19 | + message: c.message, | |
| 20 | + } | |
| 21 | + end | |
| 22 | + }.to_json | |
| 23 | +) %> | ... | ... |
app/views/stat_graph/show.html.haml
| ... | ... | @@ -1,31 +0,0 @@ |
| 1 | -.loading-graph | |
| 2 | - %center | |
| 3 | - .loading | |
| 4 | - %h3.page_title Building repository graph. Please wait a moment. | |
| 5 | - | |
| 6 | -.stat-graph | |
| 7 | - .header.clearfix | |
| 8 | - .pull-right | |
| 9 | - %select | |
| 10 | - %option{:value => "commits"} Commits | |
| 11 | - %option{:value => "additions"} Additions | |
| 12 | - %option{:value => "deletions"} Deletions | |
| 13 | - %h3#date_header.page_title | |
| 14 | - %input#brush_change{:type => "hidden"} | |
| 15 | - .graphs | |
| 16 | - #contributors-master | |
| 17 | - #contributors.clearfix | |
| 18 | - %ol.contributors-list.clearfix | |
| 19 | - | |
| 20 | -:javascript | |
| 21 | - $(".stat-graph").hide(); | |
| 22 | - | |
| 23 | - $.ajax({ | |
| 24 | - type: "GET", | |
| 25 | - url: location.href, | |
| 26 | - complete: function() { | |
| 27 | - $(".loading-graph").hide(); | |
| 28 | - $(".stat-graph").show(); | |
| 29 | - }, | |
| 30 | - dataType: "script" | |
| 31 | - }); |
app/views/stat_graph/show.js.haml
| ... | ... | @@ -1,16 +0,0 @@ |
| 1 | -:plain | |
| 2 | - controller = new ContributorsStatGraph | |
| 3 | - controller.init(#{@log}) | |
| 4 | - | |
| 5 | - $("select").change( function () { | |
| 6 | - var field = $(this).val() | |
| 7 | - controller.set_current_field(field) | |
| 8 | - controller.redraw_master() | |
| 9 | - controller.redraw_authors() | |
| 10 | - }) | |
| 11 | - | |
| 12 | - $("#brush_change").change( function () { | |
| 13 | - controller.change_date_header() | |
| 14 | - controller.redraw_authors() | |
| 15 | - }) | |
| 16 | - |
config/routes.rb
| ... | ... | @@ -190,8 +190,8 @@ Gitlab::Application.routes.draw do |
| 190 | 190 | resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} |
| 191 | 191 | resources :compare, only: [:index, :create] |
| 192 | 192 | resources :blame, only: [:show], constraints: {id: /.+/} |
| 193 | - resources :graph, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} | |
| 194 | - resources :stat_graph, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} | |
| 193 | + resources :network, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} | |
| 194 | + resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} | |
| 195 | 195 | match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/} |
| 196 | 196 | |
| 197 | 197 | scope module: :projects do | ... | ... |
features/steps/project/project_graph.rb
features/steps/project/project_network_graph.rb
| ... | ... | @@ -12,7 +12,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps |
| 12 | 12 | Network::Graph.stub(max_count: 10) |
| 13 | 13 | |
| 14 | 14 | project = Project.find_by_name("Shop") |
| 15 | - visit project_graph_path(project, "master") | |
| 15 | + visit project_network_path(project, "master") | |
| 16 | 16 | end |
| 17 | 17 | |
| 18 | 18 | And 'page should select "master" in select box' do | ... | ... |
features/steps/shared/paths.rb
| ... | ... | @@ -149,7 +149,7 @@ module SharedPaths |
| 149 | 149 | # Stub Graph max_size to speed up test (10 commits vs. 650) |
| 150 | 150 | Network::Graph.stub(max_count: 10) |
| 151 | 151 | |
| 152 | - visit project_graph_path(@project, root_ref) | |
| 152 | + visit project_network_path(@project, root_ref) | |
| 153 | 153 | end |
| 154 | 154 | |
| 155 | 155 | step "I visit my project's issues page" do | ... | ... |
spec/routing/project_routing_spec.rb
| ... | ... | @@ -446,9 +446,15 @@ describe CompareController, "routing" do |
| 446 | 446 | end |
| 447 | 447 | end |
| 448 | 448 | |
| 449 | -describe GraphController, "routing" do | |
| 449 | +describe NetworkController, "routing" do | |
| 450 | 450 | it "to #show" do |
| 451 | - get("/gitlabhq/graph/master").should route_to('graph#show', project_id: 'gitlabhq', id: 'master') | |
| 452 | - get("/gitlabhq/graph/master.json").should route_to('graph#show', project_id: 'gitlabhq', id: 'master', format: "json") | |
| 451 | + get("/gitlabhq/network/master").should route_to('network#show', project_id: 'gitlabhq', id: 'master') | |
| 452 | + get("/gitlabhq/network/master.json").should route_to('network#show', project_id: 'gitlabhq', id: 'master', format: "json") | |
| 453 | + end | |
| 454 | +end | |
| 455 | + | |
| 456 | +describe GraphsController, "routing" do | |
| 457 | + it "to #show" do | |
| 458 | + get("/gitlabhq/graphs/master").should route_to('graphs#show', project_id: 'gitlabhq', id: 'master') | |
| 453 | 459 | end |
| 454 | 460 | end | ... | ... |