remove last commit widget, added repo size and owner info on project home page
This commit is contained in:
parent
e90277f9b5
commit
ca9098d898
5 changed files with 37 additions and 17 deletions
|
@ -1,4 +1,6 @@
|
|||
class Repository
|
||||
include Gitlab::Popen
|
||||
|
||||
# Repository directory name with namespace direcotry
|
||||
# Examples:
|
||||
# gitlab/gitolite
|
||||
|
@ -147,4 +149,21 @@ class Repository
|
|||
|
||||
file_path
|
||||
end
|
||||
|
||||
# Return repo size in megabytes
|
||||
# Cached in redis
|
||||
def size
|
||||
Rails.cache.fetch(cache_key(:size)) do
|
||||
size = popen('du -s', path_to_repo).first.strip.to_i
|
||||
(size.to_f / 1024).round(2)
|
||||
end
|
||||
end
|
||||
|
||||
def expire_cache
|
||||
Rails.cache.delete(cache_key(:size))
|
||||
end
|
||||
|
||||
def cache_key(type)
|
||||
"#{type}:#{path_with_namespace}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue