Mercurial > kallithea
changeset 1000:229437211bef beta
Optimized queries on journal, and added quick stop following action button in journal
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 06 Feb 2011 00:27:45 +0100 |
parents | 1951c35483ab |
children | 94e0541a5283 |
files | rhodecode/controllers/journal.py rhodecode/model/db.py rhodecode/templates/journal/journal.html |
diffstat | 3 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/journal.py Sat Feb 05 23:58:37 2011 +0100 +++ b/rhodecode/controllers/journal.py Sun Feb 06 00:27:45 2011 +0100 @@ -39,6 +39,7 @@ from rhodecode.model.scm import ScmModel from paste.httpexceptions import HTTPInternalServerError +from sqlalchemy.orm import joinedload log = logging.getLogger(__name__) @@ -54,7 +55,9 @@ # Return a rendered template c.following = self.sa.query(UserFollowing)\ - .filter(UserFollowing.user_id == c.rhodecode_user.user_id).all() + .filter(UserFollowing.user_id == c.rhodecode_user.user_id)\ + .options(joinedload(UserFollowing.follows_repository))\ + .all() repo_ids = [x.follows_repository.repo_id for x in c.following if x.follows_repository is not None]
--- a/rhodecode/model/db.py Sat Feb 05 23:58:37 2011 +0100 +++ b/rhodecode/model/db.py Sun Feb 06 00:27:45 2011 +0100 @@ -313,7 +313,7 @@ user = relationship('User', primaryjoin='User.user_id==UserFollowing.user_id') follows_user = relationship('User', primaryjoin='User.user_id==UserFollowing.follows_user_id') - follows_repository = relationship('Repository') + follows_repository = relationship('Repository', order_by='Repository.repo_name') class CacheInvalidation(Base, BaseModel): __tablename__ = 'cache_invalidation'
--- a/rhodecode/templates/journal/journal.html Sat Feb 05 23:58:37 2011 +0100 +++ b/rhodecode/templates/journal/journal.html Sun Feb 06 00:27:45 2011 +0100 @@ -43,7 +43,12 @@ %endif %if entry.follows_repo_id: - + + <div style="float:left;padding-right:5px"> + <span id="follow_toggle_${entry.follows_repository.repo_id}" class="following" title="${_('Stop following this repository')}" + onclick="javascript:toggleFollowingRepo(this,${entry.follows_repository.repo_id},'${str(h.get_token())}')"> + </span> + </div> %if entry.follows_repository.private: <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="/images/icons/lock.png"/> %else: