Beispiel #1
0
    def issues_with_user_in_participants(self):
        """
        Append issue updated today.
        Add all issuses, where current user is participant and
        which was changed today
        """
        activities = []
        issues = self.jira_client.search_issues(
            'Participants = currentUser() '
            'AND updated > startOfDay() ',
            expand='changelog'
        )
        today = datetime.today().date()
        for issue in issues:
            changelog = issue.changelog
            # Get history (equivalently tab History in jira interface)
            for history in changelog.histories:
                if (history.author.name != self.username or
                        parser.parse(history.created).date() < today):
                    continue

                for item in history.items:
                    if item.field == 'status':
                        activity = Activity(issue.key, date=history.created)
                        activity.name = item.toString
                        activities.append(activity)

            # Get comments are left by currentuser
            comments = self.jira_client.comments(issue)
            for comment in comments:
                if (comment.author.name == self.username and
                        parser.parse(comment.created).date() == today):
                    activity = Activity(
                        issue.key,
                        date=comment.created,
                        name=STATUS_COMMENTED
                    )
                    activities.append(activity)

            worklogs = self.jira_client.worklogs(issue)
            for worklog in worklogs:
                if (worklog.author.name == self.username and
                        parser.parse(worklog.created).date() == today):
                    activity = Activity(
                        issue.key,
                        date=worklog.created,
                        name=STATUS_WORKLOG,
                        worklog=worklog.timeSpentSeconds
                    )
                    activities.append(activity)

        return activities