Changeset - 229437211bef
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 15 years ago 2011-02-06 00:27:45
marcin@python-works.com
Optimized queries on journal, and added quick stop following action button in journal
3 files changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/journal.py
Show inline comments
 
@@ -39,6 +39,7 @@ from rhodecode.model.db import UserLog, 
 
from rhodecode.model.scm import ScmModel
 

	
 
from paste.httpexceptions import HTTPInternalServerError
 
from sqlalchemy.orm import joinedload
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -54,7 +55,9 @@ class JournalController(BaseController):
 
        # 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]
rhodecode/model/db.py
Show inline comments
 
@@ -313,7 +313,7 @@ class UserFollowing(Base, BaseModel):
 
    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'
rhodecode/templates/journal/journal.html
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general)