##// END OF EJS Templates
diff-caches: show count and size in caches view per repository.
marcink -
r2687:040668bd default
parent child Browse files
Show More
@@ -18,6 +18,7 b''
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 import os
21 import logging
22 import logging
22
23
23 from pyramid.httpexceptions import HTTPFound
24 from pyramid.httpexceptions import HTTPFound
@@ -27,6 +28,7 b' from rhodecode.apps._base import RepoApp'
27 from rhodecode.lib.auth import (
28 from rhodecode.lib.auth import (
28 LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
29 LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
29 from rhodecode.lib import helpers as h
30 from rhodecode.lib import helpers as h
31 from rhodecode.lib import system_info
30 from rhodecode.model.meta import Session
32 from rhodecode.model.meta import Session
31 from rhodecode.model.scm import ScmModel
33 from rhodecode.model.scm import ScmModel
32
34
@@ -36,8 +38,6 b' log = logging.getLogger(__name__)'
36 class RepoCachesView(RepoAppView):
38 class RepoCachesView(RepoAppView):
37 def load_default_context(self):
39 def load_default_context(self):
38 c = self._get_local_tmpl_context()
40 c = self._get_local_tmpl_context()
39
40
41 return c
41 return c
42
42
43 @LoginRequired()
43 @LoginRequired()
@@ -48,6 +48,11 b' class RepoCachesView(RepoAppView):'
48 def repo_caches(self):
48 def repo_caches(self):
49 c = self.load_default_context()
49 c = self.load_default_context()
50 c.active = 'caches'
50 c.active = 'caches'
51 cached_diffs_dir = c.rhodecode_db_repo.cached_diffs_dir
52 c.cached_diff_count = len(c.rhodecode_db_repo.cached_diffs())
53 c.cached_diff_size = 0
54 if os.path.isdir(cached_diffs_dir):
55 c.cached_diff_size = system_info.get_storage_size(cached_diffs_dir)
51
56
52 return self._get_template_context(c)
57 return self._get_template_context(c)
53
58
@@ -206,10 +206,8 b' class BaseRepository(object):'
206 def __ne__(self, other):
206 def __ne__(self, other):
207 return not self.__eq__(other)
207 return not self.__eq__(other)
208
208
209 def get_create_shadow_cache_pr_path(self, repo):
209 def get_create_shadow_cache_pr_path(self, db_repo):
210 path = os.path.join(
210 path = db_repo.cached_diffs_dir
211 os.path.dirname(self.path),
212 '.__shadow_diff_cache_repo_{}/'.format(repo.repo_id))
213 if not os.path.exists(path):
211 if not os.path.exists(path):
214 os.makedirs(path, 0755)
212 os.makedirs(path, 0755)
215 return path
213 return path
@@ -1859,6 +1859,19 b' class Repository(Base, BaseModel):'
1859 .order_by(CacheKey.cache_key)\
1859 .order_by(CacheKey.cache_key)\
1860 .all()
1860 .all()
1861
1861
1862 @property
1863 def cached_diffs_dir(self):
1864 path = self.repo_full_path
1865 return os.path.join(
1866 os.path.dirname(path),
1867 '.__shadow_diff_cache_repo_{}'.format(self.repo_id))
1868
1869 def cached_diffs(self):
1870 diff_cache_dir = self.cached_diffs_dir
1871 if os.path.isdir(diff_cache_dir):
1872 return os.listdir(diff_cache_dir)
1873 return []
1874
1862 def get_new_name(self, repo_name):
1875 def get_new_name(self, repo_name):
1863 """
1876 """
1864 returns new full repository name based on assigned group and new new
1877 returns new full repository name based on assigned group and new new
@@ -51,3 +51,22 b''
51 </div>
51 </div>
52 </div>
52 </div>
53 </div>
53 </div>
54
55
56 <div class="panel panel-default">
57 <div class="panel-heading">
58 <h3 class="panel-title">${_('Diff Caches')}</h3>
59 </div>
60 <div class="panel-body">
61 <table class="rctable edit_cache">
62 <tr>
63 <td>${_('Cached diff files')}:</td>
64 <td>${c.cached_diff_count}</td>
65 </tr>
66 <tr>
67 <td>${_('Cached diff size')}:</td>
68 <td>${h.format_byte_size(c.cached_diff_size)}</td>
69 </tr>
70 </table>
71 </div>
72 </div>
General Comments 0
You need to be logged in to leave comments. Login now