mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
activity tabs
This commit is contained in:
parent
faba8bfdad
commit
c960c3dff7
6 changed files with 105 additions and 47 deletions
|
@ -21,4 +21,6 @@ en:
|
|||
percentage: Percentage
|
||||
day: Day
|
||||
day_of_week: Day of week
|
||||
hour_of_week: Hour of week
|
||||
hour_of_week: Hour of week
|
||||
month: Month
|
||||
month_of_year: Month of year
|
|
@ -30,6 +30,10 @@ module GitStats
|
|||
@by_month ||= default_hash
|
||||
end
|
||||
|
||||
def by_month_array
|
||||
by_month.to_key_indexed_array(min_size: 12, default: 0)
|
||||
end
|
||||
|
||||
def by_year
|
||||
@by_year ||= default_hash
|
||||
end
|
||||
|
|
|
@ -29,6 +29,18 @@ module GitStats
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
def activity_by_month
|
||||
Chart.new do |f|
|
||||
f.simple_column_chart(
|
||||
title: :commits_by_month.t,
|
||||
y_text: :commits.t,
|
||||
x_text: :month.t,
|
||||
data_x: Date::ABBR_MONTHNAMES,
|
||||
data_y: @activity.by_month_array
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module GitStats
|
|||
delegate :files_by_extension, :lines_by_extension, :files_by_date, :lines_by_date,
|
||||
:lines_added_by_author, :lines_deleted_by_author, to: :repo_charts
|
||||
delegate :by_authors_wday, to: :authors_charts
|
||||
delegate :activity_by_hour, :activity_by_wday, to: :activity_charts
|
||||
delegate :activity_by_hour, :activity_by_wday, :activity_by_month, to: :activity_charts
|
||||
|
||||
attr_reader :repo
|
||||
|
||||
|
|
|
@ -1,48 +1,80 @@
|
|||
.page-header
|
||||
%h1.pagination-centered= :hour_of_day.t
|
||||
%table{:class => "table table-bordered table-condensed"}
|
||||
%tr
|
||||
%th= :hour.t
|
||||
- (0..23).each do |h|
|
||||
%th= h
|
||||
%tr
|
||||
%th= :commits.t
|
||||
- repo.activity.by_hour_array.each do |commits|
|
||||
%td= commits
|
||||
%tr
|
||||
%th= :percentage.t
|
||||
- repo.activity.by_hour_array.each do |commits|
|
||||
%td= (commits * 100.0 / repo.activity.by_hour_array.sum).round(2)
|
||||
= high_chart("activity_by_hour", charts.activity_by_hour)
|
||||
.tabbable.tabs-left
|
||||
%ul.nav.nav-tabs
|
||||
%li.active
|
||||
%a{:href => '#hour_of_day', 'data-toogle' => 'tab'}= :hour_of_day.t
|
||||
%li
|
||||
%a{:href => '#day_of_week', 'data-toogle' => 'tab'}= :day_of_week.t
|
||||
%li
|
||||
%a{:href => '#hour_of_week', 'data-toogle' => 'tab'}= :hour_of_week.t
|
||||
%li
|
||||
%a{:href => '#month_of_year', 'data-toogle' => 'tab'}= :month_of_year.t
|
||||
|
||||
.tab-content
|
||||
.tab-pane.active{id: 'hour_of_day'}
|
||||
.page-header
|
||||
%h1.pagination-centered= :hour_of_day.t
|
||||
%table{:class => "table table-bordered table-condensed"}
|
||||
%tr
|
||||
%th= :hour.t
|
||||
- (0..23).each do |h|
|
||||
%th= h
|
||||
%tr
|
||||
%th= :commits.t
|
||||
- repo.activity.by_hour_array.each do |commits|
|
||||
%td= commits
|
||||
%tr
|
||||
%th= :percentage.t
|
||||
- repo.activity.by_hour_array.each do |commits|
|
||||
%td= (commits * 100.0 / repo.activity.by_hour_array.sum).round(2)
|
||||
= high_chart("activity_by_hour", charts.activity_by_hour)
|
||||
|
||||
.tab-pane{id: 'day_of_week'}
|
||||
.page-header
|
||||
%h1.pagination-centered= :day_of_week.t
|
||||
%table{:class => "table table-bordered table-condensed"}
|
||||
%tr
|
||||
%th= :day.t
|
||||
- Date::ABBR_DAYNAMES.each do |d|
|
||||
%th= d
|
||||
%tr
|
||||
%th= :commits.t
|
||||
- repo.activity.by_wday_array.each do |commits|
|
||||
%td= commits
|
||||
%tr
|
||||
%th= :percentage.t
|
||||
- repo.activity.by_wday_array.each do |commits|
|
||||
%td= (commits * 100.0 / repo.activity.by_wday_array.sum).round(2)
|
||||
= high_chart("activity_by_wday", charts.activity_by_wday)
|
||||
|
||||
|
||||
.page-header
|
||||
%h1.pagination-centered= :day_of_week.t
|
||||
%table{:class => "table table-bordered table-condensed"}
|
||||
%tr
|
||||
%th= :day.t
|
||||
- Date::ABBR_DAYNAMES.each do |d|
|
||||
%th= d
|
||||
%tr
|
||||
%th= :commits.t
|
||||
- repo.activity.by_wday_array.each do |commits|
|
||||
%td= commits
|
||||
%tr
|
||||
%th= :percentage.t
|
||||
- repo.activity.by_wday_array.each do |commits|
|
||||
%td= (commits * 100.0 / repo.activity.by_wday_array.sum).round(2)
|
||||
= high_chart("activity_by_wday", charts.activity_by_wday)
|
||||
.tab-pane{id: 'hour_of_week'}
|
||||
.page-header
|
||||
%h1.pagination-centered= :hour_of_week.t
|
||||
%table{:class => "table table-bordered table-condensed"}
|
||||
%tr
|
||||
%th
|
||||
- (0..23).each do |h|
|
||||
%th= h
|
||||
- (0..6).each do |day|
|
||||
%tr
|
||||
%th= Date::ABBR_DAYNAMES[day]
|
||||
- (0..23).each do |hour|
|
||||
%td= repo.activity.by_wday_hour[day][hour]
|
||||
|
||||
|
||||
.page-header
|
||||
%h1.pagination-centered= :hour_of_week.t
|
||||
%table{:class => "table table-bordered table-condensed"}
|
||||
%tr
|
||||
%th
|
||||
- (0..23).each do |h|
|
||||
%th= h
|
||||
- (0..6).each do |day|
|
||||
%tr
|
||||
%th= Date::ABBR_DAYNAMES[day]
|
||||
- (0..23).each do |hour|
|
||||
%td= repo.activity.by_wday_hour[day][hour]
|
||||
.tab-pane{id: 'month_of_year'}
|
||||
.page-header
|
||||
%h1.pagination-centered= :month_of_year.t
|
||||
%table{:class => "table table-bordered table-condensed"}
|
||||
%tr
|
||||
%th= :day.t
|
||||
- Date::ABBR_MONTHNAMES.each do |m|
|
||||
%th= m
|
||||
%tr
|
||||
%th= :commits.t
|
||||
- repo.activity.by_month_array.each do |commits|
|
||||
%td= commits
|
||||
%tr
|
||||
%th= :percentage.t
|
||||
- repo.activity.by_month_array.each do |commits|
|
||||
%td= (commits * 100.0 / repo.activity.by_month_array.sum).round(2)
|
||||
= high_chart("activity_by_month", charts.activity_by_month)
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
%script{:src => "assets/jquery.min.js", :type => "text/javascript"}
|
||||
%script{:src => "assets/bootstrap/js/bootstrap.min.js", :type => "text/javascript"}
|
||||
%script{:src => "assets/highstock.js", :type => "text/javascript"}
|
||||
%script
|
||||
:plain
|
||||
$(function() {
|
||||
$('.tabbable ul a').click(function (e) {
|
||||
e.preventDefault();
|
||||
$(this).tab('show');
|
||||
})
|
||||
});
|
||||
%body
|
||||
%div.navbar.navbar-inverse.navbar-fixed-top
|
||||
%div.navbar-inner
|
||||
|
|
Loading…
Reference in a new issue