@@ -21,26 +21,34 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import calendar
import logging
from time import mktime
from datetime import datetime, timedelta
from vcs.exceptions import ChangesetError
from pylons import tmpl_context as c, request, url
from pylons.i18n.translation import _
from rhodecode.model.scm import ScmModel
from rhodecode.model.db import Statistics
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
from rhodecode.lib.base import BaseController, render
from rhodecode.lib.utils import OrderedDict, EmptyChangeset
from webhelpers.paginate import Page
from rhodecode.lib.celerylib import run_task
from rhodecode.lib.celerylib.tasks import get_commits_stats
try:
import json
except ImportError:
#python 2.5 compatibility
import simplejson as json
log = logging.getLogger(__name__)
@@ -99,14 +107,17 @@ class SummaryController(BaseController):
ts_min_y = mktime((y - 1, (td - timedelta(days=calendar.mdays[m])).month,
d, 0, 0, 0, 0, 0, 0,))
ts_min_m = mktime((y, (td - timedelta(days=calendar.mdays[m])).month,
ts_max_y = mktime((y, m, d, 0, 0, 0, 0, 0, 0,))
run_task(get_commits_stats, c.repo_info.name, ts_min_y, ts_max_y)
if c.repo_info.dbrepo.enable_statistics:
c.no_data_msg = _('No data loaded yet')
else:
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 == c.repo_info.dbrepo)\
.scalar()
@@ -119,12 +119,13 @@ class Repository(Base):
__table_args__ = (UniqueConstraint('repo_name'), {'useexisting':True},)
repo_id = Column("repo_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
repo_name = Column("repo_name", String(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=True, default=None)
repo_type = Column("repo_type", String(length=None, convert_unicode=False, assert_unicode=None), nullable=False, unique=False, default=None)
user_id = Column("user_id", Integer(), ForeignKey(u'users.user_id'), nullable=False, unique=False, default=None)
private = Column("private", Boolean(), nullable=True, unique=None, default=None)
enable_statistics = Column("statistics", Boolean(), nullable=True, unique=None, default=True)
description = Column("description", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
fork_id = Column("fork_id", Integer(), ForeignKey(u'repositories.repo_id'), nullable=True, unique=False, default=None)
user = relation('User')
fork = relation('Repository', remote_side=repo_id)
repo_to_perm = relation('RepoToPerm', cascade='all')
@@ -397,12 +397,13 @@ def RepoForm(edit=False, old_data={}, su
allow_extra_fields = True
filter_extra_fields = False
repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
ValidRepoName(edit, old_data))
description = UnicodeString(strip=True, min=1, not_empty=True)
private = StringBoolean(if_missing=False)
enable_statistics = StringBoolean(if_missing=False)
repo_type = OneOf(supported_backends)
if edit:
user = All(Int(not_empty=True), ValidRepoUser)
chained_validators = [ValidPerms]
return _RepoForm
@@ -57,13 +57,20 @@
<label for="private">${_('Private')}:</label>
</div>
<div class="checkboxes">
${h.checkbox('private',value="True")}
<div class="field">
<div class="label label-checkbox">
<label for="enable_statistics">${_('Enable statistics')}:</label>
${h.checkbox('enable_statistics',value="True")}
<div class="label">
<label for="user">${_('Owner')}:</label>
<div class="input input-small ac">
<div class="perm_ac">
@@ -190,13 +190,13 @@
}
if(no_data){
var tr = document.createElement('tr');
var td1 = document.createElement('td');
td1.innerHTML = "${_('No data loaded yet')}";
td1.innerHTML = "${c.no_data_msg}";
tr.appendChild(td1);
tbl.appendChild(tr);
YUD.get('lang_stats').appendChild(tbl);
YUE.on('code_stats_show_more','click',function(){
l = YUD.getElementsByClassName('stats_hidden')
@@ -247,13 +247,13 @@
<h5>${_('Commit activity by day / author')}</h5>
<div class="table">
%if c.no_data:
<div style="padding:0 10px 10px 15px;font-size: 1.2em;">${_('No data loaded yet')}</div>
<div style="padding:0 10px 10px 15px;font-size: 1.2em;">${c.no_data_msg}</div>
%endif:
<div id="commit_history" style="width:460px;height:300px;float:left"></div>
<div style="clear: both;height: 10px"></div>
<div id="overview" style="width:460px;height:100px;float:left"></div>
<div id="legend_data" style="clear:both;margin-top:10px;">
Status change: