BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3a8cd1fa
Unverified
Commit
3a8cd1fa
authored
Sep 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor commits graph
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
6d0ddf45
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
32 deletions
+58
-32
graphs_controller.rb
app/controllers/projects/graphs_controller.rb
+4
-27
commits.html.haml
app/views/projects/graphs/commits.html.haml
+5
-5
commits.rb
lib/gitlab/graphs/commits.rb
+49
-0
No files found.
app/controllers/projects/graphs_controller.rb
View file @
3a8cd1fa
...
...
@@ -15,33 +15,10 @@ class Projects::GraphsController < Projects::ApplicationController
def
commits
@commits
=
@project
.
repository
.
commits
(
nil
,
nil
,
2000
,
0
,
true
)
@start_date
=
@commits
.
last
.
committed_date
.
to_date
@end_date
=
@commits
.
first
.
committed_date
.
to_date
@duration
=
(
@end_date
-
@start_date
).
to_i
@authors
=
@commits
.
map
(
&
:author_email
).
uniq
.
size
@commit_per_day
=
(
@commits
.
size
.
to_f
/
@duration
).
round
(
1
)
@commits_per_week_days
=
{}
Date
::
DAYNAMES
.
each
{
|
day
|
@commits_per_week_days
[
day
]
=
0
}
@commits_per_time
=
{}
(
0
..
23
).
to_a
.
each
{
|
hour
|
@commits_per_time
[
hour
]
=
0
}
@commits_per_month
=
{}
(
1
..
31
).
to_a
.
each
{
|
day
|
@commits_per_month
[
day
]
=
0
}
@commits
.
each
do
|
commit
|
hour
=
commit
.
committed_date
.
strftime
(
'%k'
).
to_i
day_of_month
=
commit
.
committed_date
.
strftime
(
'%e'
).
to_i
weekday
=
commit
.
committed_date
.
strftime
(
'%A'
)
@commits_per_week_days
[
weekday
]
||=
0
@commits_per_week_days
[
weekday
]
+=
1
@commits_per_time
[
hour
]
||=
0
@commits_per_time
[
hour
]
+=
1
@commits_per_month
[
day_of_month
]
||=
0
@commits_per_month
[
day_of_month
]
+=
1
end
@commits_graph
=
Gitlab
::
Graphs
::
Commits
.
new
(
@commits
)
@commits_per_week_days
=
@commits_graph
.
commits_per_week_days
@commits_per_time
=
@commits_graph
.
commits_per_time
@commits_per_month
=
@commits_graph
.
commits_per_month
end
private
...
...
app/views/projects/graphs/commits.html.haml
View file @
3a8cd1fa
...
...
@@ -3,26 +3,26 @@
%p
.lead
Commits statistic for
%strong
#{
@repository
.
root_ref
}
#{
@
start_date
.
strftime
(
'%b %d'
)
}
-
#{
@
end_date
.
strftime
(
'%b %d'
)
}
#{
@
commits_graph
.
start_date
.
strftime
(
'%b %d'
)
}
-
#{
@commits_graph
.
end_date
.
strftime
(
'%b %d'
)
}
.row
.col-md-6
%ul
%li
%p
.lead
%strong
#{
@commits
.
size
}
%strong
#{
@commits
_graph
.
commits
.
size
}
commits during
%strong
#{
@duration
}
%strong
#{
@
commits_graph
.
duration
}
days
%li
%p
.lead
Average
%strong
#{
@commit_per_day
}
%strong
#{
@commit
s_graph
.
commit
_per_day
}
commits per day
%li
%p
.lead
Contributed by
%strong
#{
@authors
}
%strong
#{
@
commits_graph
.
authors
}
authors
.col-md-6
%div
...
...
lib/gitlab/graphs/commits.rb
0 → 100644
View file @
3a8cd1fa
module
Gitlab
module
Graphs
class
Commits
attr_reader
:commits
,
:start_date
,
:end_date
,
:duration
,
:commits_per_week_days
,
:commits_per_time
,
:commits_per_month
def
initialize
(
commits
)
@commits
=
commits
@start_date
=
commits
.
last
.
committed_date
.
to_date
@end_date
=
commits
.
first
.
committed_date
.
to_date
@duration
=
(
@end_date
-
@start_date
).
to_i
collect_data
end
def
authors
@authors
||=
@commits
.
map
(
&
:author_email
).
uniq
.
size
end
def
commit_per_day
@commit_per_day
||=
(
@commits
.
size
.
to_f
/
@duration
).
round
(
1
)
end
def
collect_data
@commits_per_week_days
=
{}
Date
::
DAYNAMES
.
each
{
|
day
|
@commits_per_week_days
[
day
]
=
0
}
@commits_per_time
=
{}
(
0
..
23
).
to_a
.
each
{
|
hour
|
@commits_per_time
[
hour
]
=
0
}
@commits_per_month
=
{}
(
1
..
31
).
to_a
.
each
{
|
day
|
@commits_per_month
[
day
]
=
0
}
@commits
.
each
do
|
commit
|
hour
=
commit
.
committed_date
.
strftime
(
'%k'
).
to_i
day_of_month
=
commit
.
committed_date
.
strftime
(
'%e'
).
to_i
weekday
=
commit
.
committed_date
.
strftime
(
'%A'
)
@commits_per_week_days
[
weekday
]
||=
0
@commits_per_week_days
[
weekday
]
+=
1
@commits_per_time
[
hour
]
||=
0
@commits_per_time
[
hour
]
+=
1
@commits_per_month
[
day_of_month
]
||=
0
@commits_per_month
[
day_of_month
]
+=
1
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment