Changeset - 0614862a20ec
[Not reviewed]
beta
0 5 0
Marcin Kuzminski - 14 years ago 2012-01-11 16:59:15
marcin@python-works.com
Added number of comments in changelog for each changeset
- significantly improved speed of changelog page for large repos
5 files changed with 48 insertions and 21 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changelog.py
Show inline comments
 
@@ -38,6 +38,7 @@ from rhodecode.lib.helpers import RepoPa
 
from rhodecode.lib.compat import json
 

	
 
from vcs.exceptions import RepositoryError, ChangesetDoesNotExistError
 
from rhodecode.model.db import Repository
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -75,12 +76,15 @@ class ChangelogController(BaseRepoContro
 
                                                    branch_name=branch_name)]
 
                c.total_cs = len(collection)
 
            else:
 
                collection = list(c.rhodecode_repo)
 
                collection = c.rhodecode_repo
 
                c.total_cs = len(c.rhodecode_repo)
 

	
 

	
 
            c.pagination = RepoPage(collection, page=p, item_count=c.total_cs,
 
                                    items_per_page=c.size, branch=branch_name)
 
            collection = list(c.pagination)
 
            page_revisions = [x.raw_id for x in collection]
 
            c.comments = c.rhodecode_db_repo.comments(page_revisions)
 

	
 
        except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
 
            log.error(traceback.format_exc())
 
            h.flash(str(e), category='warning')
 
@@ -92,7 +96,6 @@ class ChangelogController(BaseRepoContro
 
        c.branch_filters = [('',_('All Branches'))] + \
 
            [(k,k) for k in c.rhodecode_repo.branches.keys()]
 

	
 

	
 
        return render('changelog/changelog.html')
 

	
 
    def changelog_details(self, cs):
 
@@ -112,25 +115,16 @@ class ChangelogController(BaseRepoContro
 
            c.jsdata = json.dumps([])
 
            return
 

	
 
        revcount = min(repo_size, size)
 
        offset = 1 if p == 1 else  ((p - 1) * revcount + 1)
 
        try:
 
            rev_end = collection.index(collection[(-1 * offset)])
 
        except IndexError:
 
            rev_end = collection.index(collection[-1])
 
        rev_start = max(0, rev_end - revcount)
 

	
 
        data = []
 
        rev_end += 1
 
        revs = [x.revision for x in collection]
 

	
 
        if repo.alias == 'git':
 
            for _ in xrange(rev_start, rev_end):
 
            for _ in revs:
 
                vtx = [0, 1]
 
                edges = [[0, 0, 1]]
 
                data.append(['', vtx, edges])
 

	
 
        elif repo.alias == 'hg':
 
            revs = list(reversed(xrange(rev_start, rev_end)))
 
            c.dag = graphmod.colored(graphmod.dagwalker(repo._repo, revs))
 
            for (id, type, ctx, vtx, edges) in c.dag:
 
                if type != graphmod.CHANGESET:
rhodecode/lib/helpers.py
Show inline comments
 
@@ -607,7 +607,6 @@ class RepoPage(Page):
 

	
 
            self.items = list(self.collection[self.first_item:self.last_item + 1])
 

	
 

	
 
            # Links to previous and next page
 
            if self.page > self.first_page:
 
                self.previous_page = self.page - 1
 
@@ -791,8 +790,6 @@ def urlify_commit(text_, repository=None
 
        log.error(traceback.format_exc())
 
        pass
 

	
 
    
 

	
 
    return text_
 

	
 

	
rhodecode/model/db.py
Show inline comments
 
@@ -27,6 +27,7 @@ import os
 
import logging
 
import datetime
 
import traceback
 
from collections import defaultdict
 

	
 
from sqlalchemy import *
 
from sqlalchemy.ext.hybrid import hybrid_property
 
@@ -609,6 +610,22 @@ class Repository(Base, BaseModel):
 
    def last_change(self):
 
        return self.scm_instance.last_change
 

	
 
    def comments(self, revisions=None):
 
        """
 
        Returns comments for this repository grouped by revisions
 

	
 
        :param revisions: filter query by revisions only
 
        """
 
        cmts = ChangesetComment.query()\
 
            .filter(ChangesetComment.repo == self)
 
        if revisions:
 
            cmts = cmts.filter(ChangesetComment.revision.in_(revisions))
 
        grouped = defaultdict(list)
 
        for cmt in cmts.all():
 
            grouped[cmt.revision].append(cmt)
 
        return grouped
 

	
 

	
 
    #==========================================================================
 
    # SCM CACHE INSTANCE
 
    #==========================================================================
rhodecode/public/css/style.css
Show inline comments
 
@@ -2279,7 +2279,7 @@ h3.files_location {
 
 
#graph_content .container {
 
	border-bottom: 1px solid #DDD;
 
	height: 55px;
 
	height: 57px;
 
	overflow: hidden;
 
}
 
 
@@ -2330,8 +2330,20 @@ h3.files_location {
 
	font-weight: bold !important;
 
}
 
 
 
.right div {
 
.right .comments-container{
 
	padding-right: 5px;
 
	margin-top:1px;
 
	float:right;
 
	height:16px;
 
}
 
 
.right .comments-cnt{
 
    float: left;
 
    color: rgb(136, 136, 136); 
 
    padding-right: 2px; 
 
}
 
 
.right .changes{
 
	clear: both;
 
}
 
 
@@ -2386,6 +2398,7 @@ h3.files_location {
 
 
.right .parent {
 
	color: #666666;
 
	clear:both;
 
}
 
.right .logtags{
 
	padding: 2px 2px 2px 2px;
rhodecode/templates/changelog/changelog.html
Show inline comments
 
@@ -64,7 +64,13 @@ ${c.repo_name} ${_('Changelog')} - ${c.r
 
						</div>	
 
						<div class="right">
 
									<div id="${cs.raw_id}_changes_info" class="changes">
 
                                        <span id="${cs.raw_id}" class="changed_total tooltip" title="${_('Affected number of files, click to show more details')}">${len(cs.affected_files)}</span>
 
                                        <div id="${cs.raw_id}"  style="float:right;" class="changed_total tooltip" title="${_('Affected number of files, click to show more details')}">${len(cs.affected_files)}</div>
 
                                        <div class="comments-container">
 
                                        %if len(c.comments.get(cs.raw_id,[])) > 0:
 
                                            <div class="comments-cnt" title="${('comments')}">${len(c.comments.get(cs.raw_id,[]))}</div>
 
                                            <img src="${h.url('/images/icons/comments.png')}">
 
                                        %endif    
 
                                        </div>
 
									</div>					
 
								   %if cs.parents:
 
									%for p_cs in reversed(cs.parents):
0 comments (0 inline, 0 general)