diff --git a/rhodecode/__init__.py b/rhodecode/__init__.py --- a/rhodecode/__init__.py +++ b/rhodecode/__init__.py @@ -25,9 +25,9 @@ # along with this program. If not, see . import platform -VERSION = (1, 2, 3) +VERSION = (1, 2, 4) __version__ = '.'.join((str(each) for each in VERSION[:4])) -__dbversion__ = 3 #defines current db version for migrations +__dbversion__ = 3 # defines current db version for migrations __platform__ = platform.system() __license__ = 'GPLv3' diff --git a/rhodecode/controllers/summary.py b/rhodecode/controllers/summary.py --- a/rhodecode/controllers/summary.py +++ b/rhodecode/controllers/summary.py @@ -115,9 +115,11 @@ class SummaryController(BaseRepoControll ts_max_y = mktime(td.timetuple()) if dbrepo.enable_statistics: + c.show_stats = True c.no_data_msg = _('No data loaded yet') run_task(get_commits_stats, c.dbrepo.repo_name, ts_min_y, ts_max_y) else: + c.show_stats = False c.no_data_msg = _('Statistics are disabled for this repository') c.ts_min = ts_min_m c.ts_max = ts_max_y @@ -143,8 +145,8 @@ class SummaryController(BaseRepoControll key=lambda k: k[1])[:10] ) ) - last_rev = stats.stat_on_revision - c.repo_last_rev = c.rhodecode_repo.count() - 1 \ + last_rev = stats.stat_on_revision + 1 + c.repo_last_rev = c.rhodecode_repo.count()\ if c.rhodecode_repo.revisions else 0 if last_rev == 0 or c.repo_last_rev == 0: pass diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -100,6 +100,7 @@ def get_commits_stats(repo_name, ts_min_ log.info('running task with lockkey %s', lockkey) try: + sa = get_session() lock = l = DaemonLock(file_=jn(lockkey_path, lockkey)) # for js data compatibilty cleans the key for person from ' @@ -109,20 +110,18 @@ def get_commits_stats(repo_name, ts_min_ commits_by_day_aggregate = {} repos_path = get_repos_path() repo = get_repo(safe_str(os.path.join(repos_path, repo_name))) - repo_size = len(repo.revisions) - #return if repo have no revisions + repo_size = repo.count() + # return if repo have no revisions if repo_size < 1: lock.release() return True skip_date_limit = True parse_limit = int(config['app_conf'].get('commit_parse_limit')) - last_rev = 0 + last_rev = None last_cs = None timegetter = itemgetter('time') - sa = get_session() - dbrepo = sa.query(Repository)\ .filter(Repository.repo_name == repo_name).scalar() cur_stats = sa.query(Statistics)\ @@ -132,9 +131,9 @@ def get_commits_stats(repo_name, ts_min_ last_rev = cur_stats.stat_on_revision if last_rev == repo.get_changeset().revision and repo_size > 1: - #pass silently without any work if we're not on first revision or - #current state of parsing revision(from db marker) is the - #last revision + # pass silently without any work if we're not on first revision or + # current state of parsing revision(from db marker) is the + # last revision lock.release() return True @@ -146,8 +145,10 @@ def get_commits_stats(repo_name, ts_min_ log.debug('starting parsing %s', parse_limit) lmktime = mktime - last_rev = last_rev + 1 if last_rev > 0 else last_rev - + last_rev = last_rev + 1 if last_rev >= 0 else 0 + log.debug('Getting revisions from %s to %s' % ( + last_rev, last_rev + parse_limit) + ) for cs in repo[last_rev:last_rev + parse_limit]: last_cs = cs # remember last parsed changeset k = lmktime([cs.date.timetuple()[0], cs.date.timetuple()[1], diff --git a/rhodecode/tests/functional/test_summary.py b/rhodecode/tests/functional/test_summary.py --- a/rhodecode/tests/functional/test_summary.py +++ b/rhodecode/tests/functional/test_summary.py @@ -2,6 +2,7 @@ from rhodecode.tests import * from rhodecode.model.db import Repository from rhodecode.lib.utils import invalidate_cache + class TestSummaryController(TestController): def test_index(self): @@ -22,23 +23,22 @@ class TestSummaryController(TestControll #codes stats self._enable_stats() - invalidate_cache('get_repo_cached_%s' % HG_REPO) response = self.app.get(url(controller='summary', action='index', repo_name=HG_REPO)) - self.assertTrue("""var data = {"py": {"count": 42, "desc": """ - """["Python"]}, "rst": {"count": 11, "desc": """ - """["Rst"]}, "sh": {"count": 2, "desc": ["Bash"]}, """ - """"makefile": {"count": 1, "desc": ["Makefile", """ - """"Makefile"]}, "cfg": {"count": 1, "desc": ["Ini"]},""" - """ "css": {"count": 1, "desc": ["Css"]}, "bat": """ - """{"count": 1, "desc": ["Batch"]}};""" - in response.body) + response.mustcontain( + """var data = {"py": {"count": 42, "desc": """ + """["Python"]}, "rst": {"count": 11, "desc": """ + """["Rst"]}, "sh": {"count": 2, "desc": ["Bash"]}, """ + """"makefile": {"count": 1, "desc": ["Makefile", """ + """"Makefile"]}, "cfg": {"count": 1, "desc": ["Ini"]},""" + """ "css": {"count": 1, "desc": ["Css"]}, "bat": """ + """{"count": 1, "desc": ["Batch"]}};""" + ) # clone url... - self.assertTrue("""""" % HG_REPO in response.body) - + response.mustcontain("""""" % HG_REPO) def _enable_stats(self): r = Repository.get_by_repo_name(HG_REPO) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ requirements = [ "babel", "python-dateutil>=1.5.0,<2.0.0", "dulwich>=0.8.0,<0.9.0", - "vcs==0.2.3", + "vcs==0.2.2", "webob==1.0.8" ]