cache-commits: add option to refresh caches manually from advanced pages.

This commit is contained in:
Daniel Dourvaris 2019-12-27 14:13:35 +01:00
parent 56e0778e90
commit b686261c8e
4 changed files with 18 additions and 1 deletions

View file

@ -46,9 +46,16 @@ class RepoGroupSettingsView(RepoGroupAppView):
route_name='edit_repo_group_advanced', request_method='GET',
renderer='rhodecode:templates/admin/repo_groups/repo_group_edit.mako')
def edit_repo_group_advanced(self):
_ = self.request.translate
c = self.load_default_context()
c.active = 'advanced'
c.repo_group = self.db_repo_group
# update commit cache if GET flag is present
if self.request.GET.get('update_commit_cache'):
self.db_repo_group.update_commit_cache()
h.flash(_('updated commit cache'), category='success')
return self._get_template_context(c)
@LoginRequired()

View file

@ -60,6 +60,7 @@ class RepoSettingsView(RepoAppView):
route_name='edit_repo_advanced', request_method='GET',
renderer='rhodecode:templates/admin/repos/repo_edit.mako')
def edit_advanced(self):
_ = self.request.translate
c = self.load_default_context()
c.active = 'advanced'
@ -70,6 +71,11 @@ class RepoSettingsView(RepoAppView):
c.ver_info_dict = self.rhodecode_vcs_repo.get_hooks_info()
# update commit cache if GET flag is present
if self.request.GET.get('update_commit_cache'):
self.db_repo.update_commit_cache()
h.flash(_('updated commit cache'), category='success')
return self._get_template_context(c)
@LoginRequired()

View file

@ -8,8 +8,11 @@
(_('Owner'), lambda:base.gravatar_with_user(c.repo_group.user.email, tooltip=True), '', ''),
(_('Created on'), h.format_date(c.repo_group.created_on), '', ''),
(_('Updated on'), h.format_date(c.repo_group.updated_on), '', ''),
(_('Cached Commit source'), (h.link_to_if(source_repo_id, 'repo_id:{}'.format(source_repo_id), h.route_path('repo_summary', repo_name='_{}'.format(source_repo_id)))), '', ''),
(_('Cached Commit id'), c.repo_group.changeset_cache.get('short_id'), '', ''),
(_('Cached Commit date'), (c.repo_group.changeset_cache.get('date')), '', ''),
(_('Cached Commit repo_id'), (h.link_to_if(source_repo_id, source_repo_id, h.route_path('repo_summary', repo_name='_{}'.format(source_repo_id)))), '', ''),
(_('Cached Commit data'), lambda: h.link_to('refresh now', h.current_route_path(request, update_commit_cache=1)), '', ''),
(_('Is Personal Group'), c.repo_group.personal or False, '', ''),

View file

@ -8,6 +8,7 @@
(_('Updated on'), h.format_date(c.rhodecode_db_repo.updated_on), '', ''),
(_('Cached Commit id'), lambda: h.link_to(c.rhodecode_db_repo.changeset_cache.get('short_id'), h.route_path('repo_commit',repo_name=c.repo_name,commit_id=c.rhodecode_db_repo.changeset_cache.get('raw_id'))), '', ''),
(_('Cached Commit date'), c.rhodecode_db_repo.changeset_cache.get('date'), '', ''),
(_('Cached Commit data'), lambda: h.link_to('refresh now', h.current_route_path(request, update_commit_cache=1)), '', ''),
(_('Attached scoped tokens'), len(c.rhodecode_db_repo.scoped_tokens), '', [x.user for x in c.rhodecode_db_repo.scoped_tokens]),
(_('Pull requests source'), len(c.rhodecode_db_repo.pull_requests_source), '', ['pr_id:{}, repo:{}'.format(x.pull_request_id,x.source_repo.repo_name) for x in c.rhodecode_db_repo.pull_requests_source]),
(_('Pull requests target'), len(c.rhodecode_db_repo.pull_requests_target), '', ['pr_id:{}, repo:{}'.format(x.pull_request_id,x.target_repo.repo_name) for x in c.rhodecode_db_repo.pull_requests_target]),