# HG changeset patch # User Marcin Kuzminski # Date 2019-12-19 11:52:01 # Node ID 2f1114af5e68d6e71a144fa1d1af7b2e0f3fe3d5 # Parent 7a71b271ec8e09257ea247d1fc3e8c45fd3dea92 exported get_repos_as_dict for new grids diff --git a/rhodecode/model/repo.py b/rhodecode/model/repo.py --- a/rhodecode/model/repo.py +++ b/rhodecode/model/repo.py @@ -43,13 +43,12 @@ from rhodecode.lib.utils2 import ( from rhodecode.lib.vcs.backends import get_backend from rhodecode.model import BaseModel from rhodecode.model.db import ( - _hash_key, joinedload, or_, Repository, UserRepoToPerm, UserGroupRepoToPerm, + _hash_key, func, case, joinedload, or_, in_filter_generator, + Session, Repository, UserRepoToPerm, UserGroupRepoToPerm, UserRepoGroupToPerm, UserGroupRepoGroupToPerm, User, Permission, Statistics, UserGroup, RepoGroup, RepositoryField, UserLog) - from rhodecode.model.settings import VcsSettingsModel - log = logging.getLogger(__name__) @@ -249,26 +248,29 @@ class RepoModel(BaseModel): repos_data = [] for repo in repo_list: - cs_cache = repo.changeset_cache + # NOTE(marcink): because we use only raw column we need to load it like that + changeset_cache = Repository._load_changeset_cache( + repo.repo_id, repo._changeset_cache) + last_commit_change = Repository._load_commit_change(changeset_cache) + row = { "menu": quick_menu(repo.repo_name), "name": repo_lnk(repo.repo_name, repo.repo_type, repo.repo_state, repo.private, repo.archived, repo.fork), "name_raw": repo.repo_name.lower(), + "desc": desc(repo.description), - "last_change": last_change(repo.last_commit_change), - "last_change_raw": datetime_to_time(repo.last_commit_change), + "last_change": last_change(last_commit_change), + "last_change_raw": datetime_to_time(last_commit_change), - "last_changeset": last_rev(repo.repo_name, cs_cache), - "last_changeset_raw": cs_cache.get('revision'), + "last_changeset": last_rev(repo.repo_name, changeset_cache), + "last_changeset_raw": changeset_cache.get('revision'), - "desc": desc(repo.description_safe), - "owner": user_profile(repo.user.username), + "owner": user_profile(repo.User.username), "state": state(repo.repo_state), "rss": rss_lnk(repo.repo_name), - "atom": atom_lnk(repo.repo_name), } if admin: diff --git a/rhodecode/model/repo_group.py b/rhodecode/model/repo_group.py --- a/rhodecode/model/repo_group.py +++ b/rhodecode/model/repo_group.py @@ -36,8 +36,8 @@ from zope.cachedescriptors.property impo from rhodecode import events from rhodecode.model import BaseModel -from rhodecode.model.db import (_hash_key, - RepoGroup, UserRepoGroupToPerm, User, Permission, UserGroupRepoGroupToPerm, +from rhodecode.model.db import (_hash_key, func, or_, in_filter_generator, + Session, RepoGroup, UserRepoGroupToPerm, User, Permission, UserGroupRepoGroupToPerm, UserGroup, Repository) from rhodecode.model.settings import VcsSettingsModel, SettingsModel from rhodecode.lib.caching_query import FromCache @@ -698,6 +698,8 @@ class RepoGroupModel(BaseModel): for repo_group in repo_groups: repo_group.update_commit_cache() + + def get_repo_groups_as_dict(self, repo_group_list=None, admin=False, super_user_actions=False): @@ -721,11 +723,6 @@ class RepoGroupModel(BaseModel): last_change = last_change + datetime.timedelta(seconds=utc_offset) return _render("last_change", last_change) - def last_rev(repo_name, cs_cache): - return _render('revision', repo_name, cs_cache.get('revision'), - cs_cache.get('raw_id'), cs_cache.get('author'), - cs_cache.get('message'), cs_cache.get('date')) - def desc(desc, personal): return _render( 'repo_group_desc', desc, personal, c.visual.stylify_metatags) @@ -742,22 +739,24 @@ class RepoGroupModel(BaseModel): repo_group_data = [] for group in repo_group_list: - cs_cache = group.changeset_cache - last_repo_name = cs_cache.get('source_repo_name') - + # NOTE(marcink): because we use only raw column we need to load it like that + changeset_cache = RepoGroup._load_changeset_cache( + '', group._changeset_cache) + last_commit_change = RepoGroup._load_commit_change(changeset_cache) row = { "menu": quick_menu(group.group_name), "name": repo_group_lnk(group.group_name), "name_raw": group.group_name, - "last_change": last_change(group.last_commit_change), - "last_change_raw": datetime_to_time(group.last_commit_change), + + "last_change": last_change(last_commit_change), + "last_change_raw": datetime_to_time(last_commit_change), "last_changeset": "", "last_changeset_raw": "", - "desc": desc(group.description_safe, group.personal), + "desc": desc(group.group_description, group.personal), "top_level_repos": 0, - "owner": user_profile(group.user.username) + "owner": user_profile(group.User.username) } if admin: repo_count = group.repositories.count()