Ejemplo n.º 1
0
    def __init__(self, activity: Activity) -> None:
        super().__init__(activity)
        self.organization = self.project.organization
        self.user_id_team_lookup: Optional[Mapping[int, List[int]]] = None
        self.email_list: Set[str] = set()
        self.user_ids: Set[int] = set()
        self.deploy = get_deploy(activity)
        self.release = get_release(activity, self.organization)

        if not self.release:
            self.repos: Iterable[Mapping[str, Any]] = set()
            self.projects: Set[Project] = set()
            self.version = "unknown"
            return

        self.projects = set(self.release.projects.all())
        self.commit_list = get_commits_for_release(self.release)
        self.email_list = {
            c.author.email
            for c in self.commit_list if c.author
        }
        users = get_users_by_emails(self.email_list, self.organization)
        self.user_ids = {u.id for u in users.values()}
        self.repos = get_repos(self.commit_list, users, self.organization)
        self.environment = get_environment_for_deploy(self.deploy)
        self.group_counts_by_project = get_group_counts_by_project(
            self.release, self.projects)
        self.version = self.release.version
Ejemplo n.º 2
0
 def get_message_actions(self,
                         recipient: Team | User) -> Sequence[MessageAction]:
     if self.release:
         release = get_release(self.activity, self.project.organization)
         if release:
             return [
                 MessageAction(
                     name=project.slug,
                     url=absolute_uri(
                         f"/organizations/{project.organization.slug}/releases/{release.version}/?project={project.id}&unselectedSeries=Healthy/"
                     ),
                 ) for project in self.release.projects.all()
             ]
     return []
Ejemplo n.º 3
0
def build_deploy_buttons(
        notification: ReleaseActivityNotification) -> List[Dict[str, str]]:
    buttons = []
    if notification.release:
        release = get_release(notification.activity,
                              notification.project.organization)
        if release:
            for project in notification.release.projects.all():
                project_url = absolute_uri(
                    f"/organizations/{project.organization.slug}/releases/{release.version}/?project={project.id}&unselectedSeries=Healthy/"
                )
                buttons.append({
                    "text": project.slug,
                    "name": project.slug,
                    "type": "button",
                    "url": project_url,
                })
    return buttons