##// END OF EJS Templates
commit-cache: update repo group/repo every 5 min
marcink -
r3705:4bcb793e new-ui
parent child Browse files
Show More
@@ -705,7 +705,9 b' class HomeView(BaseAppView):'
705 705 c.repo_group = self.request.db_repo_group
706 706 repo_data, repo_group_data = self._get_groups_and_repos(c.repo_group.group_id)
707 707
708 c.repo_group.update_commit_cache()
708 # update every 5 min
709 if self.request.db_repo_group.last_commit_cache_update_diff > 60 * 5:
710 self.request.db_repo_group.update_commit_cache()
709 711
710 712 # json used to render the grids
711 713 c.repos_data = json.dumps(repo_data)
@@ -202,6 +202,10 b' class RepoSummaryView(RepoAppView):'
202 202 # Prepare the clone URL
203 203 self._prepare_and_set_clone_url(c)
204 204
205 # update every 5 min
206 if self.db_repo.last_commit_cache_update_diff > 60 * 5:
207 self.db_repo.update_commit_cache()
208
205 209 # If enabled, get statistics data
206 210
207 211 c.show_stats = bool(self.db_repo.enable_statistics)
@@ -214,6 +214,7 b' class _ToolTip(object):'
214 214 tooltip_title = escape(tooltip_title)
215 215 tooltip_title = tooltip_title.replace('<', '&lt;').replace('>', '&gt;')
216 216 return tooltip_title
217
217 218 tooltip = _ToolTip()
218 219
219 220
@@ -2185,6 +2185,10 b' class Repository(Base, BaseModel):'
2185 2185 return make_lock, currently_locked, lock_info
2186 2186
2187 2187 @property
2188 def last_commit_cache_update_diff(self):
2189 return time.time() - (safe_int(self.changeset_cache.get('updated_on')) or 0)
2190
2191 @property
2188 2192 def last_commit_change(self):
2189 2193 from rhodecode.lib.vcs.utils.helpers import parse_datetime
2190 2194 empty_date = datetime.datetime.fromtimestamp(0)
@@ -2295,6 +2299,7 b' class Repository(Base, BaseModel):'
2295 2299 message
2296 2300 date
2297 2301 author
2302 updated_on
2298 2303
2299 2304 """
2300 2305 from rhodecode.lib.vcs.backends.base import BaseChangeset
@@ -2330,6 +2335,7 b' class Repository(Base, BaseModel):'
2330 2335 if last_change_timestamp > current_timestamp:
2331 2336 cs_cache['date'] = _default
2332 2337
2338 cs_cache['updated_on'] = time.time()
2333 2339 self.changeset_cache = cs_cache
2334 2340 Session().add(self)
2335 2341 Session().commit()
@@ -2671,6 +2677,10 b' class RepoGroup(Base, BaseModel):'
2671 2677 return groups
2672 2678
2673 2679 @property
2680 def last_commit_cache_update_diff(self):
2681 return time.time() - (safe_int(self.changeset_cache.get('updated_on')) or 0)
2682
2683 @property
2674 2684 def last_commit_change(self):
2675 2685 from rhodecode.lib.vcs.utils.helpers import parse_datetime
2676 2686 empty_date = datetime.datetime.fromtimestamp(0)
@@ -2817,6 +2827,7 b' class RepoGroup(Base, BaseModel):'
2817 2827 latest_repo_cs_cache = repo_cs_cache
2818 2828 latest_repo_cs_cache['source_repo_id'] = repo.repo_id
2819 2829
2830 latest_repo_cs_cache['updated_on'] = time.time()
2820 2831 repo_group.changeset_cache = latest_repo_cs_cache
2821 2832 Session().add(repo_group)
2822 2833 Session().commit()
General Comments 0
You need to be logged in to leave comments. Login now