##// END OF EJS Templates
added cache reset, stats reset, and delete into repository settings in admin....
marcink -
r708:b9bbc0d6 beta
parent child Browse files
Show More
@@ -73,7 +73,13 b' def make_map(config):'
73 73 m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}",
74 74 action="delete_perm_user", conditions=dict(method=["DELETE"],
75 75 function=check_repo))
76
76 #settings actions
77 m.connect('repo_stats', "/repos_stats/{repo_name:.*}",
78 action="repo_stats", conditions=dict(method=["DELETE"],
79 function=check_repo))
80 m.connect('repo_cache', "/repos_cache/{repo_name:.*}",
81 action="repo_cache", conditions=dict(method=["DELETE"],
82 function=check_repo))
77 83 #ADMIN USER REST ROUTES
78 84 map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
79 85
@@ -207,6 +207,35 b' class ReposController(BaseController):'
207 207 raise HTTPInternalServerError()
208 208
209 209 @HasPermissionAllDecorator('hg.admin')
210 def repo_stats(self, repo_name):
211 """
212 DELETE an existing repository statistics
213 :param repo_name:
214 """
215
216 try:
217 repo_model = RepoModel()
218 repo_model.delete_stats(repo_name)
219 except Exception, e:
220 h.flash(_('An error occured during deletion of repository stats'),
221 category='error')
222 return redirect(url('edit_repo', repo_name=repo_name))
223
224 @HasPermissionAllDecorator('hg.admin')
225 def repo_cache(self, repo_name):
226 """
227 INVALIDATE exisitings repository cache
228 :param repo_name:
229 """
230
231 try:
232 ScmModel().mark_for_invalidation(repo_name)
233 except Exception, e:
234 h.flash(_('An error occured during cache invalidation'),
235 category='error')
236 return redirect(url('edit_repo', repo_name=repo_name))
237
238 @HasPermissionAllDecorator('hg.admin')
210 239 def show(self, repo_name, format='html'):
211 240 """GET /repos/repo_name: Show a specific item"""
212 241 # url('repo', repo_name=ID)
@@ -217,6 +246,18 b' class ReposController(BaseController):'
217 246 # url('edit_repo', repo_name=ID)
218 247 repo_model = RepoModel()
219 248 c.repo_info = repo = repo_model.get(repo_name)
249 if repo.stats:
250 last_rev = repo.stats.stat_on_revision
251 else:
252 last_rev = 0
253 c.stats_revision = last_rev
254 c.repo_last_rev = ScmModel().get(repo_name).revisions[-1]
255 if last_rev == 0:
256 c.stats_percentage = 0
257 else:
258 c.stats_percentage = '%.2f' % ((float((last_rev)) / c.repo_last_rev) * 100)
259
260
220 261 if not repo:
221 262 h.flash(_('%s repository is not mapped to db perhaps'
222 263 ' it was created or renamed from the filesystem'
@@ -97,7 +97,7 b' class Repository(Base):'
97 97 user = relation('User')
98 98 fork = relation('Repository', remote_side=repo_id)
99 99 repo_to_perm = relation('RepoToPerm', cascade='all')
100 stats = relation('Statistics', cascade='all')
100 stats = relation('Statistics', cascade='all', uselist=False)
101 101
102 102 def __repr__(self):
103 103 return "<Repository('%s:%s')>" % (self.repo_id, self.repo_name)
@@ -24,7 +24,8 b' model for handling repositories actions'
24 24 from vcs.backends import get_repo, get_backend
25 25 from datetime import datetime
26 26 from pylons import app_globals as g
27 from rhodecode.model.db import Repository, RepoToPerm, User, Permission
27 from rhodecode.model.db import Repository, RepoToPerm, User, Permission, \
28 Statistics
28 29 from rhodecode.model.meta import Session
29 30 from rhodecode.model.user import UserModel
30 31 from rhodecode.model.caching_query import FromCache
@@ -179,6 +180,17 b' class RepoModel(object):'
179 180 self.sa.rollback()
180 181 raise
181 182
183 def delete_stats(self, repo_name):
184 try:
185 self.sa.query(Statistics)\
186 .filter(Statistics.repository == self.get(repo_name)).delete()
187 self.sa.commit()
188 except:
189 log.error(traceback.format_exc())
190 self.sa.rollback()
191 raise
192
193
182 194 def __create_repo(self, repo_name, alias):
183 195 from rhodecode.lib.utils import check_repo
184 196 repo_path = os.path.join(g.base_path, repo_name)
@@ -1802,6 +1802,14 b' padding-top:1px;'
1802 1802 text-align:left;
1803 1803 }
1804 1804
1805 .refresh_icon {
1806 background:url("../images/icons/arrow_refresh.png") no-repeat scroll 3px;
1807 height:16px;
1808 padding-left:20px;
1809 padding-top:1px;
1810 text-align:left;
1811 }
1812
1805 1813 .rss_icon {
1806 1814 background:url("../images/icons/rss_16.png") no-repeat scroll 3px;
1807 1815 height:16px;
@@ -92,7 +92,7 b''
92 92 <div class="input">${h.text('ldap_port',class_='small')}</div>
93 93 </div>
94 94 <div class="field">
95 <div class="label label-checkbox"><label for="ldap_ldaps">${_('LDAPS')}</label></div>
95 <div class="label label-checkbox"><label for="ldap_ldaps">${_('Enable LDAPS')}</label></div>
96 96 <div class="checkboxes"><div class="checkbox">${h.checkbox('ldap_ldaps',True,class_='small')}</div></div>
97 97 </div>
98 98 <div class="field">
@@ -286,15 +286,42 b''
286 286 <h5>${_('Administration')}</h5>
287 287 </div>
288 288
289 <h3>${_('Statistics')}</h3>
290
291 ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
289 292 <div class="form">
293 <div class="fields">
294 ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="refresh_icon action_button",onclick="return confirm('Confirm to remove current statistics');")}
290 295
291 <h3>${_('Reset statistics')}</h3>
292 <h3>${_('Reset cache')}</h3>
293 <h3>${_('Delete')}</h3>
296 <div class="field">
297 <ul>
298 <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
299 <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
300 </ul>
301 </div>
302
303 </div>
304 </div>
305 ${h.end_form()}
306
307 <h3>${_('Cache')}</h3>
308 ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
309 <div class="form">
310 <div class="fields">
311 ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="refresh_icon action_button",onclick="return confirm('Confirm to invalidate repository cache');")}
312 </div>
313 </div>
314 ${h.end_form()}
294 315
295 316
296
317 <h3>${_('Delete')}</h3>
318 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')}
319 <div class="form">
320 <div class="fields">
321 ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
297 322 </div>
323 </div>
324 ${h.end_form()}
298 325
299 326 </div>
300 327
General Comments 0
You need to be logged in to leave comments. Login now