@@ -22,15 +22,15 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# 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
__dbversion__ = 3 # defines current db version for migrations
__platform__ = platform.system()
__license__ = 'GPLv3'
PLATFORM_WIN = ('Windows')
PLATFORM_OTHERS = ('Linux', 'Darwin', 'FreeBSD', 'OpenBSD', 'SunOS')
@@ -112,15 +112,17 @@ class SummaryController(BaseRepoControll
ts_min_m = mktime(td_1m.timetuple())
ts_min_y = mktime(td_1y.timetuple())
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
stats = self.sa.query(Statistics)\
.filter(Statistics.repository == dbrepo)\
@@ -140,14 +142,14 @@ class SummaryController(BaseRepoControll
c.trending_languages = json.dumps(OrderedDict(
sorted(lang_stats, reverse=True,
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
c.stats_percentage = '%.2f' % ((float((last_rev)) /
c.repo_last_rev) * 100)
@@ -97,60 +97,61 @@ def get_commits_stats(repo_name, ts_min_
lockkey = __get_lockkey('get_commits_stats', repo_name, ts_min_y,
ts_max_y)
lockkey_path = config['here']
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 '
akc = lambda k: person(k).replace('"', "")
co_day_auth_aggr = {}
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')
dbrepo = sa.query(Repository)\
.filter(Repository.repo_name == repo_name).scalar()
cur_stats = sa.query(Statistics)\
.filter(Statistics.repository == dbrepo).scalar()
if cur_stats is not None:
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
if cur_stats:
commits_by_day_aggregate = OrderedDict(json.loads(
cur_stats.commit_activity_combined))
co_day_auth_aggr = json.loads(cur_stats.commit_activity)
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],
cs.date.timetuple()[2], 0, 0, 0, 0, 0, 0])
if akc(cs.author) in co_day_auth_aggr:
from rhodecode.tests import *
from rhodecode.model.db import Repository
from rhodecode.lib.utils import invalidate_cache
class TestSummaryController(TestController):
def test_index(self):
self.log_user()
response = self.app.get(url(controller='summary',
action='index', repo_name=HG_REPO))
@@ -19,29 +20,28 @@ class TestSummaryController(TestControll
"""repository" src="/images/icons/lock_open.png"/>"""
in response.body)
#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"]}};"""
response.mustcontain(
"""var data = {"py": {"count": 42, "desc": """
# 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)
r.enable_statistics = True
self.sa.add(r)
self.sa.commit()
@@ -20,13 +20,13 @@ requirements = [
"mercurial>=2.0,<2.1",
"whoosh<1.8",
"celery>=2.2.5,<2.3",
"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"
]
dependency_links = [
Status change: