diff-caches: show count and size in caches view per repository.
This commit is contained in:
parent
a18e6c482e
commit
ea287e0d07
4 changed files with 41 additions and 6 deletions
|
|
@ -18,6 +18,7 @@
|
|||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
import os
|
||||
import logging
|
||||
|
||||
from pyramid.httpexceptions import HTTPFound
|
||||
|
|
@ -27,6 +28,7 @@ from rhodecode.apps._base import RepoAppView
|
|||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
|
||||
from rhodecode.lib import helpers as h
|
||||
from rhodecode.lib import system_info
|
||||
from rhodecode.model.meta import Session
|
||||
from rhodecode.model.scm import ScmModel
|
||||
|
||||
|
|
@ -36,8 +38,6 @@ log = logging.getLogger(__name__)
|
|||
class RepoCachesView(RepoAppView):
|
||||
def load_default_context(self):
|
||||
c = self._get_local_tmpl_context()
|
||||
|
||||
|
||||
return c
|
||||
|
||||
@LoginRequired()
|
||||
|
|
@ -48,6 +48,11 @@ class RepoCachesView(RepoAppView):
|
|||
def repo_caches(self):
|
||||
c = self.load_default_context()
|
||||
c.active = 'caches'
|
||||
cached_diffs_dir = c.rhodecode_db_repo.cached_diffs_dir
|
||||
c.cached_diff_count = len(c.rhodecode_db_repo.cached_diffs())
|
||||
c.cached_diff_size = 0
|
||||
if os.path.isdir(cached_diffs_dir):
|
||||
c.cached_diff_size = system_info.get_storage_size(cached_diffs_dir)
|
||||
|
||||
return self._get_template_context(c)
|
||||
|
||||
|
|
|
|||
|
|
@ -206,10 +206,8 @@ class BaseRepository(object):
|
|||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def get_create_shadow_cache_pr_path(self, repo):
|
||||
path = os.path.join(
|
||||
os.path.dirname(self.path),
|
||||
'.__shadow_diff_cache_repo_{}/'.format(repo.repo_id))
|
||||
def get_create_shadow_cache_pr_path(self, db_repo):
|
||||
path = db_repo.cached_diffs_dir
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path, 0755)
|
||||
return path
|
||||
|
|
|
|||
|
|
@ -1859,6 +1859,19 @@ class Repository(Base, BaseModel):
|
|||
.order_by(CacheKey.cache_key)\
|
||||
.all()
|
||||
|
||||
@property
|
||||
def cached_diffs_dir(self):
|
||||
path = self.repo_full_path
|
||||
return os.path.join(
|
||||
os.path.dirname(path),
|
||||
'.__shadow_diff_cache_repo_{}'.format(self.repo_id))
|
||||
|
||||
def cached_diffs(self):
|
||||
diff_cache_dir = self.cached_diffs_dir
|
||||
if os.path.isdir(diff_cache_dir):
|
||||
return os.listdir(diff_cache_dir)
|
||||
return []
|
||||
|
||||
def get_new_name(self, repo_name):
|
||||
"""
|
||||
returns new full repository name based on assigned group and new new
|
||||
|
|
|
|||
|
|
@ -51,3 +51,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">${_('Diff Caches')}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="rctable edit_cache">
|
||||
<tr>
|
||||
<td>${_('Cached diff files')}:</td>
|
||||
<td>${c.cached_diff_count}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>${_('Cached diff size')}:</td>
|
||||
<td>${h.format_byte_size(c.cached_diff_size)}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue