diff --git a/rhodecode/apps/home/views.py b/rhodecode/apps/home/views.py --- a/rhodecode/apps/home/views.py +++ b/rhodecode/apps/home/views.py @@ -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) diff --git a/rhodecode/apps/repository/views/repo_summary.py b/rhodecode/apps/repository/views/repo_summary.py --- a/rhodecode/apps/repository/views/repo_summary.py +++ b/rhodecode/apps/repository/views/repo_summary.py @@ -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) diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -214,6 +214,7 @@ class _ToolTip(object): tooltip_title = escape(tooltip_title) tooltip_title = tooltip_title.replace('<', '<').replace('>', '>') return tooltip_title + tooltip = _ToolTip() diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -2185,6 +2185,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 empty_date = datetime.datetime.fromtimestamp(0) @@ -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() @@ -2671,6 +2677,10 @@ class RepoGroup(Base, BaseModel): 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 empty_date = datetime.datetime.fromtimestamp(0) @@ -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()