@@ -25,7 +25,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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
__platform__ = platform.system()
@@ -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
@@ -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,7 +110,7 @@ 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)
repo_size = repo.count()
#return if repo have no revisions
if repo_size < 1:
lock.release()
@@ -117,12 +118,10 @@ def get_commits_stats(repo_name, ts_min_
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')
dbrepo = sa.query(Repository)\
.filter(Repository.repo_name == repo_name).scalar()
cur_stats = sa.query(Statistics)\
@@ -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],
@@ -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": """
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"]}};"""
in response.body)
# clone url...
self.assertTrue("""<input type="text" id="clone_url" readonly="readonly" value="hg clone http://test_admin@localhost:80/%s" size="70"/>""" % HG_REPO in response.body)
response.mustcontain("""<input type="text" id="clone_url" readonly="readonly" value="hg clone http://test_admin@localhost:80/%s" size="70"/>""" % HG_REPO)
def _enable_stats(self):
r = Repository.get_by_repo_name(HG_REPO)
@@ -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"
]
Status change: