Changeset - 590d5b7a2b26
[Not reviewed]
default
0 3 0
Søren Løvborg - 9 years ago 2016-09-15 15:13:27
sorenl@unity3d.com
db: do case-insensitive explicit sorting of RepoGroup names

This does not change the implicit sorting enabled via __mapper_args__,
which is a bad idea anyway (and now deprecated), and will have to be
dealt with in a later changeset.

The use of __mapper_args__ implicitly adds sorting to every query of
RepoGroup objects throughout the code (including implicit queries via
relationships). For the relationships, __mapper_args can be replaced
with "order_by" on each individual relationship, and it's reasonably
straight-forward to identify every RepoGroup query throughout the code,
and add explicit sorting. But we don't really need that sorting most
of the time, so a better way forward may be to identify all the places
that actually needs the sorting, make it explicit there, and then kill
the __mapper_args__. (Anyway, future work.)
3 files changed with 3 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/repo_groups.py
Show inline comments
 
@@ -303,8 +303,7 @@ class RepoGroupsController(BaseControlle
 
        #overwrite our cached list with current filter
 
        c.repo_cnt = 0
 

	
 
        groups = RepoGroup.query().order_by(RepoGroup.group_name) \
 
            .filter(RepoGroup.group_parent_id == c.group.group_id).all()
 
        groups = RepoGroup.query(sorted=True).filter_by(parent_group=c.group).all()
 
        c.groups = self.scm_model.get_repo_groups(groups)
 

	
 
        c.repos_list = Repository.query(sorted=True).filter_by(group=c.group).all()
kallithea/controllers/home.py
Show inline comments
 
@@ -74,7 +74,7 @@ class HomeController(BaseController):
 
            log.debug('generating switcher repo/groups list')
 
            all_repos = Repository.query(sorted=True).all()
 
            repo_iter = self.scm_model.get_repos(all_repos)
 
            all_groups = RepoGroup.query().order_by(RepoGroup.group_name).all()
 
            all_groups = RepoGroup.query(sorted=True).all()
 
            repo_groups_iter = self.scm_model.get_repo_groups(all_groups)
 

	
 
            res = [{
kallithea/model/db.py
Show inline comments
 
@@ -1518,7 +1518,7 @@ class RepoGroup(Base, BaseModel):
 
        CheckConstraint('group_id != group_parent_id', name='ck_groups_no_self_parent'),
 
        _table_args_default_dict,
 
    )
 
    __mapper_args__ = {'order_by': 'group_name'}
 
    __mapper_args__ = {'order_by': 'group_name'} # TODO: Deprecated as of SQLAlchemy 1.1.
 

	
 
    SEP = ' » '
 

	
0 comments (0 inline, 0 general)