# HG changeset patch # User Daniel Dourvaris # Date 2016-06-22 10:38:11 # Node ID 1cc12c9113be3eae78d3b77beea4a1ed0fb0d57f # Parent 27f3d68226efc11d1e9b13077293e3a31c13647a speedup: check identity_map when getting by repo name diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1374,10 +1374,9 @@ class Repository(Base, BaseModel): @classmethod def get_by_repo_name(cls, repo_name): session = Session() - for (klass, pkey), instance in session.identity_map.items(): - if cls == klass: - if getattr(instance, 'repo_name') == repo_name: - return instance + for (item_cls, pkey), instance in session.identity_map.items(): + if cls == item_cls and instance.repo_name == repo_name: + return instance q = session.query(cls).filter(cls.repo_name == repo_name) q = q.options(joinedload(Repository.fork))\