Commit 5baac66992a1a4e3df4f9873632a9a083e52b92c
1 parent
63e532ef
Exists in
master
and in
4 other branches
More info (like 10 branches, 5 tags) at project show page
Showing
2 changed files
with
41 additions
and
5 deletions
Show diff stats
app/models/repository.rb
@@ -33,6 +33,18 @@ class Repository | @@ -33,6 +33,18 @@ class Repository | ||
33 | commits | 33 | commits |
34 | end | 34 | end |
35 | 35 | ||
36 | + def round_commit_count | ||
37 | + if commit_count > 10000 | ||
38 | + '10000+' | ||
39 | + elsif commit_count > 5000 | ||
40 | + '5000+' | ||
41 | + elsif commit_count > 1000 | ||
42 | + '1000+' | ||
43 | + else | ||
44 | + commit_count | ||
45 | + end | ||
46 | + end | ||
47 | + | ||
36 | def branch_names | 48 | def branch_names |
37 | Rails.cache.fetch(cache_key(:branch_names)) do | 49 | Rails.cache.fetch(cache_key(:branch_names)) do |
38 | raw_repository.branch_names | 50 | raw_repository.branch_names |
@@ -45,8 +57,10 @@ class Repository | @@ -45,8 +57,10 @@ class Repository | ||
45 | end | 57 | end |
46 | end | 58 | end |
47 | 59 | ||
48 | - def method_missing(m, *args, &block) | ||
49 | - raw_repository.send(m, *args, &block) | 60 | + def commit_count |
61 | + Rails.cache.fetch(cache_key(:commit_count)) do | ||
62 | + raw_repository.raw.commit_count | ||
63 | + end | ||
50 | end | 64 | end |
51 | 65 | ||
52 | # Return repo size in megabytes | 66 | # Return repo size in megabytes |
@@ -61,6 +75,7 @@ class Repository | @@ -61,6 +75,7 @@ class Repository | ||
61 | Rails.cache.delete(cache_key(:size)) | 75 | Rails.cache.delete(cache_key(:size)) |
62 | Rails.cache.delete(cache_key(:branch_names)) | 76 | Rails.cache.delete(cache_key(:branch_names)) |
63 | Rails.cache.delete(cache_key(:tag_names)) | 77 | Rails.cache.delete(cache_key(:tag_names)) |
78 | + Rails.cache.delete(cache_key(:commit_count)) | ||
64 | Rails.cache.delete(cache_key(:graph_log)) | 79 | Rails.cache.delete(cache_key(:graph_log)) |
65 | end | 80 | end |
66 | 81 | ||
@@ -75,6 +90,10 @@ class Repository | @@ -75,6 +90,10 @@ class Repository | ||
75 | "#{type}:#{path_with_namespace}" | 90 | "#{type}:#{path_with_namespace}" |
76 | end | 91 | end |
77 | 92 | ||
93 | + def method_missing(m, *args, &block) | ||
94 | + raw_repository.send(m, *args, &block) | ||
95 | + end | ||
96 | + | ||
78 | def respond_to?(method) | 97 | def respond_to?(method) |
79 | return true if raw_repository.respond_to?(method) | 98 | return true if raw_repository.respond_to?(method) |
80 | 99 |
app/views/projects/show.html.haml
@@ -37,9 +37,18 @@ | @@ -37,9 +37,18 @@ | ||
37 | 37 | ||
38 | %hr | 38 | %hr |
39 | %p | 39 | %p |
40 | - %p Repo Size: #{@project.repository.size} MB | ||
41 | - %p Created on: #{@project.created_at.stamp('Aug 22, 2013')} | ||
42 | - %p Owner: #{link_to @project.owner_name, @project.owner} | 40 | + %p |
41 | + %span.light Repo size is | ||
42 | + #{@project.repository.size} MB | ||
43 | + %p | ||
44 | + %span.light Created at | ||
45 | + #{@project.created_at.stamp('Aug 22, 2013')} | ||
46 | + %p | ||
47 | + %span.light Owned by | ||
48 | + - if @project.group | ||
49 | + #{link_to @project.group.name, @project.group} Group | ||
50 | + - else | ||
51 | + #{link_to @project.owner_name, @project.owner} | ||
43 | - if @project.forked_from_project | 52 | - if @project.forked_from_project |
44 | %p | 53 | %p |
45 | %i.icon-code-fork | 54 | %i.icon-code-fork |
@@ -50,3 +59,11 @@ | @@ -50,3 +59,11 @@ | ||
50 | %hr | 59 | %hr |
51 | = link_to @project.gitlab_ci_service.builds_path do | 60 | = link_to @project.gitlab_ci_service.builds_path do |
52 | = image_tag @project.gitlab_ci_service.status_img_path, alt: "build status" | 61 | = image_tag @project.gitlab_ci_service.status_img_path, alt: "build status" |
62 | + | ||
63 | + %hr | ||
64 | + %p | ||
65 | + = link_to pluralize(@repository.round_commit_count, 'commit'), project_commits_path(@project) | ||
66 | + %p | ||
67 | + = link_to pluralize(@repository.branch_names.count, 'branch'), project_repository_path(@project) | ||
68 | + %p | ||
69 | + = link_to pluralize(@repository.tag_names.count, 'tag'), tags_project_repository_path(@project) |