mirror of
https://github.com/tomgi/git_stats.git
synced 2024-09-29 12:11:29 +02:00
activity charts
This commit is contained in:
parent
65bbdfa87a
commit
6fc44905cb
@ -24,7 +24,10 @@ en:
|
|||||||
hour_of_week: Hour of week
|
hour_of_week: Hour of week
|
||||||
month: Month
|
month: Month
|
||||||
month_of_year: Month of year
|
month_of_year: Month of year
|
||||||
|
year_month: Year and month
|
||||||
commits_by_wday: Commits by day of week
|
commits_by_wday: Commits by day of week
|
||||||
commits_by_month: Commits by month of year
|
commits_by_month: Commits by month
|
||||||
|
commits_by_year_month: Commits by year and month
|
||||||
|
commits_by_month_of_year: Commits by month of year
|
||||||
year: Year
|
year: Year
|
||||||
commits_by_year: Commits by year
|
commits_by_year: Commits by year
|
@ -1,21 +0,0 @@
|
|||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe GitStats::StatsView::Charts::ActivityCharts do
|
|
||||||
let(:charts) { GitStats::StatsView::Charts::All.new(repo) }
|
|
||||||
|
|
||||||
context 'activity_by_hour chart' do
|
|
||||||
let(:activity) { double(by_hour: double(to_key_indexed_array: 'result')) }
|
|
||||||
let(:repo) { double(activity: activity) }
|
|
||||||
let(:chart) { charts.activity_charts.activity_by_hour }
|
|
||||||
|
|
||||||
it 'should be a column chart' do
|
|
||||||
chart.should be_a GitStats::StatsView::Charts::Chart
|
|
||||||
chart.options[:chart][:type].should == "column"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have 1 data series with activity by_hour' do
|
|
||||||
chart.should have(1).data
|
|
||||||
chart.data.first[:data].should == activity.by_hour.to_key_indexed_array
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,28 +0,0 @@
|
|||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe GitStats::StatsView::Charts::AuthorsCharts do
|
|
||||||
let(:charts) { GitStats::StatsView::Charts::All.new(repo) }
|
|
||||||
|
|
||||||
context 'by_authors_wday chart' do
|
|
||||||
let(:authors) { [
|
|
||||||
double(email: "email1", activity: double(by_wday: double(to_key_indexed_array: "result1"))),
|
|
||||||
double(email: "email2", activity: double(by_wday: double(to_key_indexed_array: "result2")))
|
|
||||||
] }
|
|
||||||
let(:repo) { double(authors: authors) }
|
|
||||||
let(:chart) { charts.authors_charts.by_authors_wday }
|
|
||||||
|
|
||||||
it 'should be a column chart' do
|
|
||||||
chart.should be_a GitStats::StatsView::Charts::Chart
|
|
||||||
chart.options[:chart][:type].should == "column"
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should have 2 data series with authors activity by_wday' do
|
|
||||||
chart.should have(2).data
|
|
||||||
chart.data[0][:data].should == "result1"
|
|
||||||
chart.data[0][:name].should == "email1"
|
|
||||||
|
|
||||||
chart.data[1][:data].should == "result2"
|
|
||||||
chart.data[1][:name].should == "email2"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,84 +0,0 @@
|
|||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
shared_examples_for "column_chart" do
|
|
||||||
it 'should be a column chart' do
|
|
||||||
chart.should be_a GitStats::StatsView::Charts::Chart
|
|
||||||
chart.options[:chart][:type].should == "column"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe GitStats::StatsView::Charts::RepoCharts do
|
|
||||||
let(:charts) { GitStats::StatsView::Charts::All.new(repo) }
|
|
||||||
|
|
||||||
context 'files_by_extension chart' do
|
|
||||||
let(:repo) { double(files_by_extension_count: {'.rb' => 5, '.txt' => 3}) }
|
|
||||||
let(:chart) { charts.files_by_extension }
|
|
||||||
|
|
||||||
it_behaves_like "column_chart"
|
|
||||||
|
|
||||||
it 'should have 1 data series with files_by_extension_count' do
|
|
||||||
chart.should have(1).data
|
|
||||||
chart.options[:xAxis][:categories].should == %w(.rb .txt)
|
|
||||||
chart.data[0][:data].should == [5, 3]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'lines_by_extension chart' do
|
|
||||||
let(:repo) { double(lines_by_extension: {'.rb' => 50, '.txt' => 30}) }
|
|
||||||
let(:chart) { charts.lines_by_extension }
|
|
||||||
|
|
||||||
it_behaves_like "column_chart"
|
|
||||||
|
|
||||||
it 'should have 1 data series with lines_by_extension' do
|
|
||||||
chart.should have(1).data
|
|
||||||
chart.options[:xAxis][:categories].should == %w(.rb .txt)
|
|
||||||
chart.data[0][:data].should == [50, 30]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'files_by_date chart' do
|
|
||||||
let(:repo) { double(commits: [double(date: 5)], files_count_by_date: {1 => 10, 2 => 15, 3 => 12, 5 => 20}) }
|
|
||||||
let(:chart) { charts.files_by_date }
|
|
||||||
|
|
||||||
it 'should have 1 data series with files_by_date' do
|
|
||||||
chart.should have(1).data
|
|
||||||
chart.data[0][:data].should == [[1000, 10], [2000, 15], [3000, 12], [5000, 20]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'lines_by_date chart' do
|
|
||||||
let(:repo) { double(commits: [double(date: 6)], lines_count_by_date: {1 => 100, 2 => 150, 3 => 120, 5 => 200}) }
|
|
||||||
let(:chart) { charts.lines_by_date }
|
|
||||||
|
|
||||||
it 'should have 1 data series with lines_by_date' do
|
|
||||||
chart.should have(1).data
|
|
||||||
chart.data[0][:data].should == [[1000, 100], [2000, 150], [3000, 120], [5000, 200]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'lines_added_by_author chart' do
|
|
||||||
let(:repo) { double(commits: [double(date: 6)], lines_added_by_author: {double(email: 'author1') => 50, double(email: 'author2') => 30}) }
|
|
||||||
let(:chart) { charts.lines_added_by_author }
|
|
||||||
|
|
||||||
it_behaves_like "column_chart"
|
|
||||||
|
|
||||||
it 'should have 1 data series with lines_added_by_author' do
|
|
||||||
chart.should have(1).data
|
|
||||||
chart.options[:xAxis][:categories].should == %w(author1 author2)
|
|
||||||
chart.data[0][:data].should == [50, 30]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'lines_deleted_by_author chart' do
|
|
||||||
let(:repo) { double(commits: [double(date: 6)], lines_deleted_by_author: {double(email: 'author1') => 30, double(email: 'author2') => 50}) }
|
|
||||||
let(:chart) { charts.lines_deleted_by_author }
|
|
||||||
|
|
||||||
it_behaves_like "column_chart"
|
|
||||||
|
|
||||||
it 'should have 1 data series with lines_deleted_by_author' do
|
|
||||||
chart.should have(1).data
|
|
||||||
chart.options[:xAxis][:categories].should == %w(author1 author2)
|
|
||||||
chart.data[0][:data].should == [30, 50]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -10,6 +10,8 @@
|
|||||||
%a{:href => '#month_of_year', 'data-toogle' => 'tab'}= :month_of_year.t
|
%a{:href => '#month_of_year', 'data-toogle' => 'tab'}= :month_of_year.t
|
||||||
%li
|
%li
|
||||||
%a{:href => '#year', 'data-toogle' => 'tab'}= :year.t
|
%a{:href => '#year', 'data-toogle' => 'tab'}= :year.t
|
||||||
|
%li
|
||||||
|
%a{:href => '#year_month', 'data-toogle' => 'tab'}= :year_month.t
|
||||||
|
|
||||||
.tab-content
|
.tab-content
|
||||||
.tab-pane.active{id: 'hour_of_day'}
|
.tab-pane.active{id: 'hour_of_day'}
|
||||||
@ -86,3 +88,18 @@
|
|||||||
.page-header
|
.page-header
|
||||||
%h1.pagination-centered= :year.t
|
%h1.pagination-centered= :year.t
|
||||||
= high_chart("activity_by_year", charts.activity_by_year)
|
= high_chart("activity_by_year", charts.activity_by_year)
|
||||||
|
|
||||||
|
|
||||||
|
.tab-pane{id: 'year_month'}
|
||||||
|
.page-header
|
||||||
|
%h1.pagination-centered= :year_month.t
|
||||||
|
%table{:class => "table table-bordered table-condensed"}
|
||||||
|
%tr
|
||||||
|
%th
|
||||||
|
- Date::ABBR_MONTHNAMES[1..-1].each do |h|
|
||||||
|
%th= h
|
||||||
|
- repo.activity.by_year_month.each do |year, months|
|
||||||
|
%tr
|
||||||
|
%th= year
|
||||||
|
- (1..12).each do |month|
|
||||||
|
%td= months[month]
|
Loading…
Reference in New Issue
Block a user