Commit e7a3b2c7 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor-graphs' into 'master'

Refactor graphs

This is first step of refactoring graphs. It includes removing all outdated and non-working stuff.

Related to #1590

See merge request !1123
parents fd338d67 aa46a15d
...@@ -31,7 +31,7 @@ gem 'omniauth-shibboleth' ...@@ -31,7 +31,7 @@ gem 'omniauth-shibboleth'
# Extracting information from a git repository # Extracting information from a git repository
# Provide access to Gitlab::Git library # Provide access to Gitlab::Git library
gem "gitlab_git", '7.0.0.rc2' gem "gitlab_git", '7.0.0.rc3'
# Ruby/Rack Git Smart-HTTP Server Handler # Ruby/Rack Git Smart-HTTP Server Handler
gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
......
...@@ -179,7 +179,7 @@ GEM ...@@ -179,7 +179,7 @@ GEM
mime-types (~> 1.19) mime-types (~> 1.19)
gitlab_emoji (0.0.1.1) gitlab_emoji (0.0.1.1)
emoji (~> 1.0.1) emoji (~> 1.0.1)
gitlab_git (7.0.0.rc2) gitlab_git (7.0.0.rc3)
activesupport (~> 4.0) activesupport (~> 4.0)
charlock_holmes (~> 0.6) charlock_holmes (~> 0.6)
gitlab-linguist (~> 3.0) gitlab-linguist (~> 3.0)
...@@ -618,7 +618,7 @@ DEPENDENCIES ...@@ -618,7 +618,7 @@ DEPENDENCIES
gitlab-grack (~> 2.0.0.pre) gitlab-grack (~> 2.0.0.pre)
gitlab-linguist (~> 3.0.0) gitlab-linguist (~> 3.0.0)
gitlab_emoji (~> 0.0.1.1) gitlab_emoji (~> 0.0.1.1)
gitlab_git (= 7.0.0.rc2) gitlab_git (= 7.0.0.rc3)
gitlab_meta (= 7.0) gitlab_meta (= 7.0)
gitlab_omniauth-ldap (= 1.1.0) gitlab_omniauth-ldap (= 1.1.0)
gollum-lib (~> 3.0.0) gollum-lib (~> 3.0.0)
......
...@@ -24,22 +24,7 @@ class window.ContributorsStatGraph ...@@ -24,22 +24,7 @@ class window.ContributorsStatGraph
class: 'graph-author-commits-count' class: 'graph-author-commits-count'
}) })
commits.text(author.commits + " commits") commits.text(author.commits + " commits")
additions = $('<span/>', {
class: 'graph-additions'
})
additions.text(author.additions + " ++")
deletions = $('<span/>', {
class: 'graph-deletions'
})
deletions.text(author.deletions + " --")
$('<span/>').append(commits) $('<span/>').append(commits)
.append(" / ")
.append(additions)
.append(" / ")
.append(deletions)
create_author_header: (author) -> create_author_header: (author) ->
list_item = $('<li/>', { list_item = $('<li/>', {
......
...@@ -7,7 +7,7 @@ class Projects::GraphsController < Projects::ApplicationController ...@@ -7,7 +7,7 @@ class Projects::GraphsController < Projects::ApplicationController
def show def show
respond_to do |format| respond_to do |format|
format.html format.html
format.js do format.json do
fetch_graph fetch_graph
end end
end end
...@@ -16,10 +16,17 @@ class Projects::GraphsController < Projects::ApplicationController ...@@ -16,10 +16,17 @@ class Projects::GraphsController < Projects::ApplicationController
private private
def fetch_graph def fetch_graph
@log = @project.repository.graph_log.to_json @commits = @project.repository.commits(nil, nil, 6000, 0, true)
@success = true
rescue => ex
@log = [] @log = []
@success = false
@commits.each do |commit|
@log << {
author_name: commit.author_name.force_encoding('UTF-8'),
author_email: commit.author_email.force_encoding('UTF-8'),
date: commit.committed_date.strftime("%Y-%m-%d")
}
end
render json: @log.to_json
end end
end end
...@@ -4,11 +4,6 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -4,11 +4,6 @@ class Projects::RepositoriesController < Projects::ApplicationController
before_filter :authorize_code_access! before_filter :authorize_code_access!
before_filter :require_non_empty_project before_filter :require_non_empty_project
def stats
@stats = Gitlab::Git::Stats.new(@repository.raw_repository, @repository.root_ref)
@graph = @stats.graph
end
def archive def archive
unless can?(current_user, :download_code, @project) unless can?(current_user, :download_code, @project)
render_404 and return render_404 and return
......
...@@ -32,7 +32,7 @@ class Repository ...@@ -32,7 +32,7 @@ class Repository
commit commit
end end
def commits(ref, path = nil, limit = nil, offset = nil) def commits(ref, path = nil, limit = nil, offset = nil, skip_merges = false)
commits = Gitlab::Git::Commit.where( commits = Gitlab::Git::Commit.where(
repo: raw_repository, repo: raw_repository,
ref: ref, ref: ref,
......
...@@ -13,7 +13,3 @@ ...@@ -13,7 +13,3 @@
= link_to project_tags_path(@project) do = link_to project_tags_path(@project) do
Tags Tags
%span.badge.js-totaltags-count= @repository.tags.length %span.badge.js-totaltags-count= @repository.tags.length
= nav_link(controller: :repositories, action: :stats) do
= link_to stats_project_repository_path(@project) do
Stats
...@@ -3,15 +3,10 @@ ...@@ -3,15 +3,10 @@
%h3.page-title %h3.page-title
%i.icon-spinner.icon-spin %i.icon-spinner.icon-spin
Building repository graph. Building repository graph.
%p Please wait a moment, this page will automatically refresh when ready. %p.slead Please wait a moment, this page will automatically refresh when ready.
.stat-graph .stat-graph.hide
.header.clearfix .header.clearfix
.pull-right
%select
%option{:value => "commits"} Commits
%option{:value => "additions"} Additions
%option{:value => "deletions"} Deletions
%h3#date_header.page-title %h3#date_header.page-title
%p.light %p.light
Commits to #{@project.default_branch}, excluding merge commits. Limited by 6,000 commits Commits to #{@project.default_branch}, excluding merge commits. Limited by 6,000 commits
...@@ -21,15 +16,21 @@ ...@@ -21,15 +16,21 @@
#contributors.clearfix #contributors.clearfix
%ol.contributors-list.clearfix %ol.contributors-list.clearfix
:javascript
$(".stat-graph").hide();
$.ajax({
:coffeescript
$.ajax
type: "GET", type: "GET",
url: location.href, url: location.href,
complete: function() { success: (data) ->
graph = new ContributorsStatGraph()
graph.init(data)
$("#brush_change").change ->
graph.change_date_header()
graph.redraw_authors()
$(".stat-graph").fadeIn(); $(".stat-graph").fadeIn();
$(".loading-graph").hide(); $(".loading-graph").hide();
}, dataType: "json"
dataType: "script"
});
- if @success
:plain
controller = new ContributorsStatGraph
controller.init(#{@log})
$("select").change( function () {
var field = $(this).val()
controller.set_current_field(field)
controller.redraw_master()
controller.redraw_authors()
})
$("#brush_change").change( function () {
controller.change_date_header()
controller.redraw_authors()
})
- else
:plain
$('.stat-graph').replaceWith('<div class="alert alert-danger">Failed to load graph</div>')
= render "projects/commits/head"
.row
.col-md-6
%div#activity-chart.chart
%hr
%p
%b Total commits:
%span= @repository.commit_count
%p
%b Total files in #{@repository.root_ref}:
%span= @stats.files_count
%p
%b Authors:
%span= @stats.authors_count
.col-md-6
%h4 Top 50 Committers:
%ol.styled
- @stats.authors[0...50].each do |author|
%li
= image_tag avatar_icon(author.email, 16), class: 'avatar s16', alt: ''
= author.name
%small.light= author.email
.pull-right
= author.commits
:javascript
var labels = [#{@graph.labels.to_json}];
var commits = [#{@graph.commits.join(', ')}];
var title = "Commit activity for last #{@graph.weeks} weeks";
Chart.init(labels, commits, title);
...@@ -230,7 +230,6 @@ Gitlab::Application.routes.draw do ...@@ -230,7 +230,6 @@ Gitlab::Application.routes.draw do
resource :repository, only: [:show] do resource :repository, only: [:show] do
member do member do
get "stats"
get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex } get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex }
end end
end end
......
...@@ -30,9 +30,10 @@ Feature: Project Browse commits ...@@ -30,9 +30,10 @@ Feature: Project Browse commits
Given I visit my project's commits page for a specific path Given I visit my project's commits page for a specific path
Then I see breadcrumb links Then I see breadcrumb links
Scenario: I browse commits stats # TODO: Implement feature in graphs
Given I visit my project's commits stats page #Scenario: I browse commits stats
Then I see commits stats #Given I visit my project's commits stats page
#Then I see commits stats
Scenario: I browse big commit Scenario: I browse big commit
Given I visit big commit page Given I visit big commit page
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment