Show More
@@ -25,9 +25,9 b'' | |||||
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
26 | import platform |
|
26 | import platform | |
27 |
|
27 | |||
28 |
VERSION = (1, 2, |
|
28 | VERSION = (1, 2, 4) | |
29 | __version__ = '.'.join((str(each) for each in VERSION[:4])) |
|
29 | __version__ = '.'.join((str(each) for each in VERSION[:4])) | |
30 | __dbversion__ = 3 #defines current db version for migrations |
|
30 | __dbversion__ = 3 # defines current db version for migrations | |
31 | __platform__ = platform.system() |
|
31 | __platform__ = platform.system() | |
32 | __license__ = 'GPLv3' |
|
32 | __license__ = 'GPLv3' | |
33 |
|
33 |
@@ -115,9 +115,11 b' class SummaryController(BaseRepoControll' | |||||
115 | ts_max_y = mktime(td.timetuple()) |
|
115 | ts_max_y = mktime(td.timetuple()) | |
116 |
|
116 | |||
117 | if dbrepo.enable_statistics: |
|
117 | if dbrepo.enable_statistics: | |
|
118 | c.show_stats = True | |||
118 | c.no_data_msg = _('No data loaded yet') |
|
119 | c.no_data_msg = _('No data loaded yet') | |
119 | run_task(get_commits_stats, c.dbrepo.repo_name, ts_min_y, ts_max_y) |
|
120 | run_task(get_commits_stats, c.dbrepo.repo_name, ts_min_y, ts_max_y) | |
120 | else: |
|
121 | else: | |
|
122 | c.show_stats = False | |||
121 | c.no_data_msg = _('Statistics are disabled for this repository') |
|
123 | c.no_data_msg = _('Statistics are disabled for this repository') | |
122 | c.ts_min = ts_min_m |
|
124 | c.ts_min = ts_min_m | |
123 | c.ts_max = ts_max_y |
|
125 | c.ts_max = ts_max_y | |
@@ -143,8 +145,8 b' class SummaryController(BaseRepoControll' | |||||
143 | key=lambda k: k[1])[:10] |
|
145 | key=lambda k: k[1])[:10] | |
144 | ) |
|
146 | ) | |
145 | ) |
|
147 | ) | |
146 | last_rev = stats.stat_on_revision |
|
148 | last_rev = stats.stat_on_revision + 1 | |
147 |
c.repo_last_rev = c.rhodecode_repo.count() |
|
149 | c.repo_last_rev = c.rhodecode_repo.count()\ | |
148 | if c.rhodecode_repo.revisions else 0 |
|
150 | if c.rhodecode_repo.revisions else 0 | |
149 | if last_rev == 0 or c.repo_last_rev == 0: |
|
151 | if last_rev == 0 or c.repo_last_rev == 0: | |
150 | pass |
|
152 | pass |
@@ -100,6 +100,7 b' def get_commits_stats(repo_name, ts_min_' | |||||
100 |
|
100 | |||
101 | log.info('running task with lockkey %s', lockkey) |
|
101 | log.info('running task with lockkey %s', lockkey) | |
102 | try: |
|
102 | try: | |
|
103 | sa = get_session() | |||
103 | lock = l = DaemonLock(file_=jn(lockkey_path, lockkey)) |
|
104 | lock = l = DaemonLock(file_=jn(lockkey_path, lockkey)) | |
104 |
|
105 | |||
105 | # for js data compatibilty cleans the key for person from ' |
|
106 | # for js data compatibilty cleans the key for person from ' | |
@@ -109,20 +110,18 b' def get_commits_stats(repo_name, ts_min_' | |||||
109 | commits_by_day_aggregate = {} |
|
110 | commits_by_day_aggregate = {} | |
110 | repos_path = get_repos_path() |
|
111 | repos_path = get_repos_path() | |
111 | repo = get_repo(safe_str(os.path.join(repos_path, repo_name))) |
|
112 | repo = get_repo(safe_str(os.path.join(repos_path, repo_name))) | |
112 |
repo_size = |
|
113 | repo_size = repo.count() | |
113 | #return if repo have no revisions |
|
114 | # return if repo have no revisions | |
114 | if repo_size < 1: |
|
115 | if repo_size < 1: | |
115 | lock.release() |
|
116 | lock.release() | |
116 | return True |
|
117 | return True | |
117 |
|
118 | |||
118 | skip_date_limit = True |
|
119 | skip_date_limit = True | |
119 | parse_limit = int(config['app_conf'].get('commit_parse_limit')) |
|
120 | parse_limit = int(config['app_conf'].get('commit_parse_limit')) | |
120 |
last_rev = |
|
121 | last_rev = None | |
121 | last_cs = None |
|
122 | last_cs = None | |
122 | timegetter = itemgetter('time') |
|
123 | timegetter = itemgetter('time') | |
123 |
|
124 | |||
124 | sa = get_session() |
|
|||
125 |
|
||||
126 | dbrepo = sa.query(Repository)\ |
|
125 | dbrepo = sa.query(Repository)\ | |
127 | .filter(Repository.repo_name == repo_name).scalar() |
|
126 | .filter(Repository.repo_name == repo_name).scalar() | |
128 | cur_stats = sa.query(Statistics)\ |
|
127 | cur_stats = sa.query(Statistics)\ | |
@@ -132,9 +131,9 b' def get_commits_stats(repo_name, ts_min_' | |||||
132 | last_rev = cur_stats.stat_on_revision |
|
131 | last_rev = cur_stats.stat_on_revision | |
133 |
|
132 | |||
134 | if last_rev == repo.get_changeset().revision and repo_size > 1: |
|
133 | if last_rev == repo.get_changeset().revision and repo_size > 1: | |
135 | #pass silently without any work if we're not on first revision or |
|
134 | # pass silently without any work if we're not on first revision or | |
136 | #current state of parsing revision(from db marker) is the |
|
135 | # current state of parsing revision(from db marker) is the | |
137 | #last revision |
|
136 | # last revision | |
138 | lock.release() |
|
137 | lock.release() | |
139 | return True |
|
138 | return True | |
140 |
|
139 | |||
@@ -146,8 +145,10 b' def get_commits_stats(repo_name, ts_min_' | |||||
146 | log.debug('starting parsing %s', parse_limit) |
|
145 | log.debug('starting parsing %s', parse_limit) | |
147 | lmktime = mktime |
|
146 | lmktime = mktime | |
148 |
|
147 | |||
149 |
last_rev = last_rev + 1 if last_rev > 0 else |
|
148 | last_rev = last_rev + 1 if last_rev >= 0 else 0 | |
150 |
|
149 | log.debug('Getting revisions from %s to %s' % ( | ||
|
150 | last_rev, last_rev + parse_limit) | |||
|
151 | ) | |||
151 | for cs in repo[last_rev:last_rev + parse_limit]: |
|
152 | for cs in repo[last_rev:last_rev + parse_limit]: | |
152 | last_cs = cs # remember last parsed changeset |
|
153 | last_cs = cs # remember last parsed changeset | |
153 | k = lmktime([cs.date.timetuple()[0], cs.date.timetuple()[1], |
|
154 | k = lmktime([cs.date.timetuple()[0], cs.date.timetuple()[1], |
@@ -2,6 +2,7 b' from rhodecode.tests import *' | |||||
2 | from rhodecode.model.db import Repository |
|
2 | from rhodecode.model.db import Repository | |
3 | from rhodecode.lib.utils import invalidate_cache |
|
3 | from rhodecode.lib.utils import invalidate_cache | |
4 |
|
4 | |||
|
5 | ||||
5 | class TestSummaryController(TestController): |
|
6 | class TestSummaryController(TestController): | |
6 |
|
7 | |||
7 | def test_index(self): |
|
8 | def test_index(self): | |
@@ -22,23 +23,22 b' class TestSummaryController(TestControll' | |||||
22 | #codes stats |
|
23 | #codes stats | |
23 | self._enable_stats() |
|
24 | self._enable_stats() | |
24 |
|
25 | |||
25 |
|
||||
26 | invalidate_cache('get_repo_cached_%s' % HG_REPO) |
|
26 | invalidate_cache('get_repo_cached_%s' % HG_REPO) | |
27 | response = self.app.get(url(controller='summary', action='index', |
|
27 | response = self.app.get(url(controller='summary', action='index', | |
28 | repo_name=HG_REPO)) |
|
28 | repo_name=HG_REPO)) | |
29 |
|
29 | |||
30 | self.assertTrue("""var data = {"py": {"count": 42, "desc": """ |
|
30 | response.mustcontain( | |
31 |
|
|
31 | """var data = {"py": {"count": 42, "desc": """ | |
32 |
|
|
32 | """["Python"]}, "rst": {"count": 11, "desc": """ | |
33 |
|
|
33 | """["Rst"]}, "sh": {"count": 2, "desc": ["Bash"]}, """ | |
34 |
|
|
34 | """"makefile": {"count": 1, "desc": ["Makefile", """ | |
35 |
|
|
35 | """"Makefile"]}, "cfg": {"count": 1, "desc": ["Ini"]},""" | |
36 |
|
|
36 | """ "css": {"count": 1, "desc": ["Css"]}, "bat": """ | |
37 | in response.body) |
|
37 | """{"count": 1, "desc": ["Batch"]}};""" | |
|
38 | ) | |||
38 |
|
39 | |||
39 | # clone url... |
|
40 | # clone url... | |
40 |
se |
|
41 | response.mustcontain("""<input type="text" id="clone_url" readonly="readonly" value="hg clone http://test_admin@localhost:80/%s" size="70"/>""" % HG_REPO) | |
41 |
|
||||
42 |
|
42 | |||
43 | def _enable_stats(self): |
|
43 | def _enable_stats(self): | |
44 | r = Repository.get_by_repo_name(HG_REPO) |
|
44 | r = Repository.get_by_repo_name(HG_REPO) |
General Comments 0
You need to be logged in to leave comments.
Login now