示例#1
0
    def _fillwith_notifMessages(self, notifMessages):
        repo_ids = [x.repo_id for x in notifMessages]
        userprofile_ids = [x.user_id for x in notifMessages]
        repo_dict = dict(
            (x.id, x) for x in RepoManager.list_repo_by_ids(repo_ids))
        userprofile_dict = dict(
            (x.id, x)
            for x in GsuserManager.list_userprofile_by_ids(userprofile_ids))
        for notifMessage in notifMessages:
            if notifMessage.repo_id in repo_dict:
                notifMessage.repo = repo_dict[notifMessage.repo_id]
            if notifMessage.from_user_id in userprofile_dict:
                notifMessage.from_userprofile = userprofile_dict[
                    notifMessage.from_user_id]

            if notifMessage.is_at_commit():
                commitHistory = RepoManager.get_commit_by_id(
                    notifMessage.relative_id)
                notifMessage.relative_obj = commitHistory
            elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
                issue = IssueManager.get_issue_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = issue
            elif notifMessage.is_at_merge(
            ) or notifMessage.is_pull_request_cate():
                pullRequest = RepoManager.get_pullRequest_by_id(
                    notifMessage.relative_id)
                notifMessage.relative_obj = pullRequest
            elif notifMessage.is_at_issue_comment():
                issue_comment = IssueManager.get_issue_comment(
                    notifMessage.relative_id)
                notifMessage.relative_obj = issue_comment
        return notifMessages
示例#2
0
 def list_feed_by_ids(self, ids):
     feeds = get_many(Feed, ids)
     user_ids = Set([x.user_id for x in feeds])
     userprofile_dict = dict((x.id, x) for x in GsuserManager.list_userprofile_by_ids(user_ids))
     for feed in feeds:
         if feed.user_id in userprofile_dict:
             feed.userprofile = userprofile_dict[feed.user_id]
     return feeds
示例#3
0
 def list_feed_by_ids(self, ids):
     feeds = get_many(Feed, ids)
     user_ids = Set([x.user_id for x in feeds])
     userprofile_dict = dict(
         (x.id, x) for x in GsuserManager.list_userprofile_by_ids(user_ids))
     for feed in feeds:
         if feed.user_id in userprofile_dict:
             feed.userprofile = userprofile_dict[feed.user_id]
     return feeds
示例#4
0
 def list_groupMember_by_teamGroupId(self, group_id):
     groupMembers = query(GroupMember, group_id, 'groupmember_l_groupId', [group_id])
     user_ids = [x.member_user_id for x in groupMembers]
     userprofiles = GsuserManager.list_userprofile_by_ids(user_ids)
     userprofile_dict = dict((x.id, x)for x in userprofiles)
     for x in groupMembers:
         if x.member_user_id in userprofile_dict:
             x.member_userprofile = userprofile_dict[x.member_user_id]
     return groupMembers
示例#5
0
 def list_repo_team_memberUser(self, repo_id):
     repo = self.get_repo_by_id(repo_id)
     if not repo:
         return []
     repoemembers = self.list_repomember(repo_id)
     user_ids = [x.user_id for x in repoemembers]
     userprofile = GsuserManager.get_userprofile_by_id(repo.user_id)
     if not userprofile:
         return []
     if userprofile.is_team_account == 0:
         user_ids.insert(0, repo.user_id)
     if userprofile.is_team_account == 1:
         teamMembers = TeamManager.list_teamMember_by_teamUserId(userprofile.id)
         for x in teamMembers:
             if x.user_id not in user_ids:
                 user_ids.append(x.user_id)
     return GsuserManager.list_userprofile_by_ids(user_ids)
示例#6
0
 def list_repo_team_memberUser(self, repo_id):
     repo = self.get_repo_by_id(repo_id)
     if not repo:
         return []
     repoemembers = self.list_repomember(repo_id)
     user_ids = [x.user_id for x in repoemembers]
     userprofile = GsuserManager.get_userprofile_by_id(repo.user_id)
     if not userprofile:
         return []
     if userprofile.is_team_account == 0:
         user_ids.insert(0, repo.user_id)
     if userprofile.is_team_account == 1:
         teamMembers = TeamManager.list_teamMember_by_teamUserId(
             userprofile.id)
         for x in teamMembers:
             if x.user_id not in user_ids:
                 user_ids.append(x.user_id)
     return GsuserManager.list_userprofile_by_ids(user_ids)
示例#7
0
    def _fillwith_notifMessages(self, notifMessages):
        repo_ids = [x.repo_id for x in notifMessages]
        userprofile_ids = [x.user_id for x in notifMessages]
        repo_dict = dict((x.id, x) for x in RepoManager.list_repo_by_ids(repo_ids))
        userprofile_dict = dict((x.id, x) for x in GsuserManager.list_userprofile_by_ids(userprofile_ids))
        for notifMessage in notifMessages:
            if notifMessage.repo_id in repo_dict:
                notifMessage.repo = repo_dict[notifMessage.repo_id]
            if notifMessage.from_user_id in userprofile_dict:
                notifMessage.from_userprofile = userprofile_dict[notifMessage.from_user_id]

            if notifMessage.is_at_commit():
                commitHistory = RepoManager.get_commit_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = commitHistory
            elif notifMessage.is_at_issue() or notifMessage.is_issue_cate():
                issue = IssueManager.get_issue_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = issue
            elif notifMessage.is_at_merge() or notifMessage.is_pull_request_cate():
                pullRequest = RepoManager.get_pullRequest_by_id(notifMessage.relative_id)
                notifMessage.relative_obj = pullRequest
            elif notifMessage.is_at_issue_comment():
                issue_comment = IssueManager.get_issue_comment(notifMessage.relative_id)
                notifMessage.relative_obj = issue_comment
        return notifMessages