Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f0a6fbaa
Commit
f0a6fbaa
authored
Nov 13, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Commits stats code
parent
b28ab896
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
app/views/repositories/stats.html.haml
app/views/repositories/stats.html.haml
+5
-3
lib/gitlab/git_stats.rb
lib/gitlab/git_stats.rb
+6
-9
No files found.
app/views/repositories/stats.html.haml
View file @
f0a6fbaa
...
...
@@ -2,12 +2,12 @@
.row
.span5
%h4
Stats
for
#{
@project
.
root_ref
}
:
Stats:
%p
%b
Total commits:
%span
=
@stats
.
commits_count
%p
%b
Total files:
%b
Total files
in
#{
@project
.
root_ref
}
:
%span
=
@stats
.
files_count
%p
%b
Authors:
...
...
@@ -30,10 +30,12 @@
:javascript
$
(
function
(){
var
labels
=
[
#{
@graph
.
labels
.
to_json
}
];
var
commits
=
[
#{
@graph
.
commits
.
join
(
', '
)
}
];
var
r
=
Raphael
(
'
activity-chart
'
);
r
.
text
(
160
,
10
,
"
Commit activity for last
#{
@graph
.
weeks
}
weeks
"
).
attr
({
font
:
"
13px sans-serif
"
});
r
.
barchart
(
10
,
10
,
400
,
160
,
[[
#{
@graph
.
commits
.
join
(
', '
)
}
]]
[
commits
],
{
colors
:[
"
#456
"
]}
).
label
(
labels
,
true
);
})
lib/gitlab/git_stats.rb
View file @
f0a6fbaa
...
...
@@ -15,7 +15,8 @@ module Gitlab
end
def
files_count
repo
.
git
.
sh
(
"git ls-tree -r --name-only
#{
ref
}
| wc -l"
).
first
.
to_i
args
=
[
ref
,
'-r'
,
'--name-only'
]
repo
.
git
.
run
(
nil
,
'ls-tree'
,
nil
,
{},
args
).
split
(
"
\n
"
).
count
end
def
authors_count
...
...
@@ -52,15 +53,11 @@ module Gitlab
def
build_graph
n
=
4
from
,
to
=
(
Date
.
today
-
n
.
weeks
),
Date
.
today
args
=
[
'--all'
,
"--since=
#{
from
.
to_s
(
:date
)
}
"
,
'--format=%ad'
]
rev_list
=
repo
.
git
.
run
(
nil
,
'rev-list'
,
nil
,
{},
args
).
split
(
"
\n
"
)
format
=
"--pretty=format:'%h|%at|%ai|%aE'"
commits_strings
=
repo
.
git
.
sh
(
"git rev-list --since
#{
from
.
to_s
(
:date
)
}
#{
format
}
#{
ref
}
| grep -v commit"
)[
0
].
split
(
"
\n
"
)
commits_dates
=
commits_strings
.
map
do
|
string
|
data
=
string
.
split
(
"|"
)
date
=
data
[
2
]
Time
.
parse
(
date
).
to_date
.
to_s
(
:date
)
end
commits_dates
=
rev_list
.
values_at
(
*
rev_list
.
each_index
.
select
{
|
i
|
i
.
odd?
})
commits_dates
=
commits_dates
.
map
{
|
date_str
|
Time
.
parse
(
date_str
).
to_date
.
to_s
(
:date
)
}
commits_per_day
=
from
.
upto
(
to
).
map
do
|
day
|
commits_dates
.
count
(
day
.
to_date
.
to_s
(
:date
))
...
...
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