commit-cache: update repo group/repo every 5 min
This commit is contained in:
parent
b825888302
commit
565bfc3141
4 changed files with 19 additions and 1 deletions
|
|
@ -705,7 +705,9 @@ class HomeView(BaseAppView):
|
|||
c.repo_group = self.request.db_repo_group
|
||||
repo_data, repo_group_data = self._get_groups_and_repos(c.repo_group.group_id)
|
||||
|
||||
c.repo_group.update_commit_cache()
|
||||
# update every 5 min
|
||||
if self.request.db_repo_group.last_commit_cache_update_diff > 60 * 5:
|
||||
self.request.db_repo_group.update_commit_cache()
|
||||
|
||||
# json used to render the grids
|
||||
c.repos_data = json.dumps(repo_data)
|
||||
|
|
|
|||
|
|
@ -202,6 +202,10 @@ class RepoSummaryView(RepoAppView):
|
|||
# Prepare the clone URL
|
||||
self._prepare_and_set_clone_url(c)
|
||||
|
||||
# update every 5 min
|
||||
if self.db_repo.last_commit_cache_update_diff > 60 * 5:
|
||||
self.db_repo.update_commit_cache()
|
||||
|
||||
# If enabled, get statistics data
|
||||
|
||||
c.show_stats = bool(self.db_repo.enable_statistics)
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ class _ToolTip(object):
|
|||
tooltip_title = escape(tooltip_title)
|
||||
tooltip_title = tooltip_title.replace('<', '<').replace('>', '>')
|
||||
return tooltip_title
|
||||
|
||||
tooltip = _ToolTip()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2184,6 +2184,10 @@ class Repository(Base, BaseModel):
|
|||
|
||||
return make_lock, currently_locked, lock_info
|
||||
|
||||
@property
|
||||
def last_commit_cache_update_diff(self):
|
||||
return time.time() - (safe_int(self.changeset_cache.get('updated_on')) or 0)
|
||||
|
||||
@property
|
||||
def last_commit_change(self):
|
||||
from rhodecode.lib.vcs.utils.helpers import parse_datetime
|
||||
|
|
@ -2295,6 +2299,7 @@ class Repository(Base, BaseModel):
|
|||
message
|
||||
date
|
||||
author
|
||||
updated_on
|
||||
|
||||
"""
|
||||
from rhodecode.lib.vcs.backends.base import BaseChangeset
|
||||
|
|
@ -2330,6 +2335,7 @@ class Repository(Base, BaseModel):
|
|||
if last_change_timestamp > current_timestamp:
|
||||
cs_cache['date'] = _default
|
||||
|
||||
cs_cache['updated_on'] = time.time()
|
||||
self.changeset_cache = cs_cache
|
||||
Session().add(self)
|
||||
Session().commit()
|
||||
|
|
@ -2670,6 +2676,10 @@ class RepoGroup(Base, BaseModel):
|
|||
groups.insert(0, gr)
|
||||
return groups
|
||||
|
||||
@property
|
||||
def last_commit_cache_update_diff(self):
|
||||
return time.time() - (safe_int(self.changeset_cache.get('updated_on')) or 0)
|
||||
|
||||
@property
|
||||
def last_commit_change(self):
|
||||
from rhodecode.lib.vcs.utils.helpers import parse_datetime
|
||||
|
|
@ -2817,6 +2827,7 @@ class RepoGroup(Base, BaseModel):
|
|||
latest_repo_cs_cache = repo_cs_cache
|
||||
latest_repo_cs_cache['source_repo_id'] = repo.repo_id
|
||||
|
||||
latest_repo_cs_cache['updated_on'] = time.time()
|
||||
repo_group.changeset_cache = latest_repo_cs_cache
|
||||
Session().add(repo_group)
|
||||
Session().commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue