Show More
@@ -40,11 +40,10 b' import celery.utils.log' | |||||
40 | from tg import config |
|
40 | from tg import config | |
41 |
|
41 | |||
42 | import kallithea |
|
42 | import kallithea | |
43 | import kallithea.lib.helpers as h |
|
|||
44 | from kallithea.lib import celerylib, conf, ext_json, hooks |
|
43 | from kallithea.lib import celerylib, conf, ext_json, hooks | |
45 | from kallithea.lib.indexers.daemon import WhooshIndexingDaemon |
|
44 | from kallithea.lib.indexers.daemon import WhooshIndexingDaemon | |
46 | from kallithea.lib.utils2 import asbool, ascii_bytes |
|
45 | from kallithea.lib.utils2 import asbool, ascii_bytes | |
47 | from kallithea.lib.vcs.utils import author_email |
|
46 | from kallithea.lib.vcs.utils import author_email, author_name | |
48 | from kallithea.model import db, repo, userlog |
|
47 | from kallithea.model import db, repo, userlog | |
49 |
|
48 | |||
50 |
|
49 | |||
@@ -66,6 +65,19 b' def whoosh_index(repo_location, full_ind' | |||||
66 | .run(full_index=full_index) |
|
65 | .run(full_index=full_index) | |
67 |
|
66 | |||
68 |
|
67 | |||
|
68 | def _author_username(author): | |||
|
69 | """Return the username of the user identified by the email part of the 'author' string, | |||
|
70 | default to the name or email. | |||
|
71 | Kind of similar to h.person() .""" | |||
|
72 | email = author_email(author) | |||
|
73 | if email: | |||
|
74 | user = db.User.get_by_email(email) | |||
|
75 | if user is not None: | |||
|
76 | return user.username | |||
|
77 | # Still nothing? Just pass back the author name if any, else the email | |||
|
78 | return author_name(author) or email | |||
|
79 | ||||
|
80 | ||||
69 | @celerylib.task |
|
81 | @celerylib.task | |
70 | @celerylib.dbsession |
|
82 | @celerylib.dbsession | |
71 | def get_commits_stats(repo_name, ts_min_y, ts_max_y, recurse_limit=100): |
|
83 | def get_commits_stats(repo_name, ts_min_y, ts_max_y, recurse_limit=100): | |
@@ -124,13 +136,19 b' def get_commits_stats(repo_name, ts_min_' | |||||
124 | log.debug('Getting revisions from %s to %s', |
|
136 | log.debug('Getting revisions from %s to %s', | |
125 | last_rev, last_rev + parse_limit |
|
137 | last_rev, last_rev + parse_limit | |
126 | ) |
|
138 | ) | |
|
139 | usernames_cache = {} | |||
127 | for cs in scm_repo[last_rev:last_rev + parse_limit]: |
|
140 | for cs in scm_repo[last_rev:last_rev + parse_limit]: | |
128 | log.debug('parsing %s', cs) |
|
141 | log.debug('parsing %s', cs) | |
129 | last_cs = cs # remember last parsed changeset |
|
142 | last_cs = cs # remember last parsed changeset | |
130 | tt = cs.date.timetuple() |
|
143 | tt = cs.date.timetuple() | |
131 | k = mktime(tt[:3] + (0, 0, 0, 0, 0, 0)) |
|
144 | k = mktime(tt[:3] + (0, 0, 0, 0, 0, 0)) | |
132 |
|
145 | |||
133 | username = h.person(cs.author) |
|
146 | # get username from author - similar to what h.person does | |
|
147 | username = usernames_cache.get(cs.author) | |||
|
148 | if username is None: | |||
|
149 | username = _author_username(cs.author) | |||
|
150 | usernames_cache[cs.author] = username | |||
|
151 | ||||
134 | if username in co_day_auth_aggr: |
|
152 | if username in co_day_auth_aggr: | |
135 | try: |
|
153 | try: | |
136 | l = [timegetter(x) for x in |
|
154 | l = [timegetter(x) for x in |
@@ -158,7 +158,6 b' known_violations = [' | |||||
158 | ('kallithea.lib.utils', 'kallithea.model'), # clean up utils |
|
158 | ('kallithea.lib.utils', 'kallithea.model'), # clean up utils | |
159 | ('kallithea.lib.utils', 'kallithea.model.db'), |
|
159 | ('kallithea.lib.utils', 'kallithea.model.db'), | |
160 | ('kallithea.lib.utils', 'kallithea.model.scm'), |
|
160 | ('kallithea.lib.utils', 'kallithea.model.scm'), | |
161 | ('kallithea.model.async_tasks', 'kallithea.lib.helpers'), |
|
|||
162 | ('kallithea.model.async_tasks', 'kallithea.lib.hooks'), |
|
161 | ('kallithea.model.async_tasks', 'kallithea.lib.hooks'), | |
163 | ('kallithea.model.async_tasks', 'kallithea.lib.indexers'), |
|
162 | ('kallithea.model.async_tasks', 'kallithea.lib.indexers'), | |
164 | ('kallithea.model.async_tasks', 'kallithea.model'), |
|
163 | ('kallithea.model.async_tasks', 'kallithea.model'), |
General Comments 0
You need to be logged in to leave comments.
Login now