##// END OF EJS Templates
code-review initial
marcink -
r2215:2c2bdaec codereview
parent child Browse files
Show More
@@ -84,7 +84,7 b' class ChangelogController(BaseRepoContro'
84 collection = list(c.pagination)
84 collection = list(c.pagination)
85 page_revisions = [x.raw_id for x in collection]
85 page_revisions = [x.raw_id for x in collection]
86 c.comments = c.rhodecode_db_repo.comments(page_revisions)
86 c.comments = c.rhodecode_db_repo.comments(page_revisions)
87
87 c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
88 except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
88 except (RepositoryError, ChangesetDoesNotExistError, Exception), e:
89 log.error(traceback.format_exc())
89 log.error(traceback.format_exc())
90 h.flash(str(e), category='warning')
90 h.flash(str(e), category='warning')
@@ -203,10 +203,16 b' class ChangesetController(BaseRepoContro'
203 c.cut_off = False # defines if cut off limit is reached
203 c.cut_off = False # defines if cut off limit is reached
204
204
205 c.comments = []
205 c.comments = []
206 c.statuses = []
206 c.inline_comments = []
207 c.inline_comments = []
207 c.inline_cnt = 0
208 c.inline_cnt = 0
208 # Iterate over ranges (default changeset view is always one changeset)
209 # Iterate over ranges (default changeset view is always one changeset)
209 for changeset in c.cs_ranges:
210 for changeset in c.cs_ranges:
211
212 c.statuses.extend(ChangesetStatusModel()\
213 .get_status(c.rhodecode_db_repo.repo_id,
214 changeset.raw_id))
215
210 c.comments.extend(ChangesetCommentsModel()\
216 c.comments.extend(ChangesetCommentsModel()\
211 .get_comments(c.rhodecode_db_repo.repo_id,
217 .get_comments(c.rhodecode_db_repo.repo_id,
212 changeset.raw_id))
218 changeset.raw_id))
@@ -1,5 +1,7 b''
1 from __future__ import with_statement
1 from __future__ import with_statement
2
2
3 import gc
4 import objgraph
3 import cProfile
5 import cProfile
4 import pstats
6 import pstats
5 import cgi
7 import cgi
@@ -26,7 +28,7 b' class ProfilingMiddleware(object):'
26 profiler.snapshot_stats()
28 profiler.snapshot_stats()
27
29
28 stats = pstats.Stats(profiler)
30 stats = pstats.Stats(profiler)
29 stats.sort_stats('cumulative')
31 stats.sort_stats('calls') #cummulative
30
32
31 # Redirect output
33 # Redirect output
32 out = StringIO()
34 out = StringIO()
@@ -44,6 +46,11 b' class ProfilingMiddleware(object):'
44 'border-top: 4px dashed red; padding: 1em;">')
46 'border-top: 4px dashed red; padding: 1em;">')
45 resp += cgi.escape(out.getvalue(), True)
47 resp += cgi.escape(out.getvalue(), True)
46
48
49 ct = objgraph.show_most_common_types()
50 print ct
51
52 resp += ct if ct else '---'
53
47 output = StringIO()
54 output = StringIO()
48 pprint.pprint(environ, output, depth=3)
55 pprint.pprint(environ, output, depth=3)
49
56
@@ -34,6 +34,8 b' from sqlalchemy.ext.hybrid import hybrid'
34 from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
34 from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
35 from beaker.cache import cache_region, region_invalidate
35 from beaker.cache import cache_region, region_invalidate
36
36
37 _ = lambda s: s
38
37 from rhodecode.lib.vcs import get_backend
39 from rhodecode.lib.vcs import get_backend
38 from rhodecode.lib.vcs.utils.helpers import get_scm
40 from rhodecode.lib.vcs.utils.helpers import get_scm
39 from rhodecode.lib.vcs.exceptions import VCSError
41 from rhodecode.lib.vcs.exceptions import VCSError
@@ -675,6 +677,23 b' class Repository(Base, BaseModel):'
675 grouped[cmt.revision].append(cmt)
677 grouped[cmt.revision].append(cmt)
676 return grouped
678 return grouped
677
679
680 def statuses(self, revisions=None):
681 """
682 Returns statuses for this repository
683 :param revisions: list of revisions to get statuses for
684 :type revisions: list
685 """
686
687 statuses = ChangesetStatus.query()\
688 .filter(ChangesetStatus.repo == self)
689 if revisions:
690 statuses = statuses.filter(ChangesetStatus.revision.in_(revisions))
691 grouped = defaultdict(list)
692 for stat in statuses.all():
693 grouped[statuses.revision].append(stat)
694 return grouped
695
696
678 #==========================================================================
697 #==========================================================================
679 # SCM CACHE INSTANCE
698 # SCM CACHE INSTANCE
680 #==========================================================================
699 #==========================================================================
@@ -1207,6 +1226,44 b' class ChangesetComment(Base, BaseModel):'
1207 .join(ChangesetComment.author).all()
1226 .join(ChangesetComment.author).all()
1208
1227
1209
1228
1229 class ChangesetStatus(Base, BaseModel):
1230 __tablename__ = 'changeset_statuses'
1231 __table_args__ = (
1232 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1233 'mysql_charset': 'utf8'}
1234 )
1235
1236 STATUSES = [
1237 ('not_reviewed', _("Not Reviewed")), # (no icon) and default
1238 ('approved', _("Approved")),
1239 ('rejected', _("Rejected")),
1240 ('under_review', _("Under Review")),
1241 ]
1242
1243 changeset_status_id = Column('changeset_status_id', Integer(), nullable=False, primary_key=True)
1244 repo_id = Column('repo_id', Integer(), ForeignKey('repositories.repo_id'), nullable=False)
1245 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None)
1246 revision = Column('revision', String(40), nullable=False)
1247 status = Column('status', String(128), nullable=False, default=STATUSES[0][0])
1248 modified_at = Column('modified_at', DateTime(), nullable=False, default=datetime.datetime.now)
1249
1250 author = relationship('User', lazy='joined')
1251 repo = relationship('Repository')
1252
1253
1254 class ChangesetStatusHistory(Base, BaseModel):
1255 __tablename__ = 'changeset_statuses_history'
1256 __table_args__ = (
1257 {'extend_existing': True, 'mysql_engine': 'InnoDB',
1258 'mysql_charset': 'utf8'}
1259 )
1260 #TODO: check if sqla has a nice history table implementation
1261 changeset_status_id = Column('changeset_status_id', Integer(), ForeignKey('changeset_statuses.changeset_status_id'), nullable=False, primary_key=True)
1262 user_id = Column("user_id", Integer(), ForeignKey('users.user_id'), nullable=False, unique=None)
1263 status = Column('status', String(128), nullable=False)
1264 modified_at = Column('modified_at', DateTime(), nullable=False, default=datetime.datetime.now)
1265
1266
1210 class Notification(Base, BaseModel):
1267 class Notification(Base, BaseModel):
1211 __tablename__ = 'notifications'
1268 __tablename__ = 'notifications'
1212 __table_args__ = (
1269 __table_args__ = (
@@ -65,6 +65,7 b''
65 <div class="right">
65 <div class="right">
66 <div id="${cs.raw_id}_changes_info" class="changes">
66 <div id="${cs.raw_id}_changes_info" class="changes">
67 <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>
67 <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>
68 <div class="changeset-status-container">${c.statuses.get(cs.raw_id)}</div>
68 <div class="comments-container">
69 <div class="comments-container">
69 %if len(c.comments.get(cs.raw_id,[])) > 0:
70 %if len(c.comments.get(cs.raw_id,[])) > 0:
70 <div class="comments-cnt" title="${('comments')}">
71 <div class="comments-cnt" title="${('comments')}">
@@ -1,3 +1,5 b''
1 ## small box that displays changed/added/removed details fetched by AJAX
2
1 % if len(c.cs.affected_files) <= c.affected_files_cut_off:
3 % if len(c.cs.affected_files) <= c.affected_files_cut_off:
2 <span class="removed tooltip" title="<b>${_('removed')}</b>${h.changed_tooltip(c.cs.removed)}">${len(c.cs.removed)}</span>
4 <span class="removed tooltip" title="<b>${_('removed')}</b>${h.changed_tooltip(c.cs.removed)}">${len(c.cs.removed)}</span>
3 <span class="changed tooltip" title="<b>${_('changed')}</b>${h.changed_tooltip(c.cs.changed)}">${len(c.cs.changed)}</span>
5 <span class="changed tooltip" title="<b>${_('changed')}</b>${h.changed_tooltip(c.cs.changed)}">${len(c.cs.changed)}</span>
General Comments 0
You need to be logged in to leave comments. Login now