Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement transition_to stats for the jira plugin #352

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions did/plugins/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
Name of the token to check for expiration in ``token_expiration``
days. This has to match the name as seen in your Jira profile.

transition_to
Name of the issue status we want to report transitions to.
Defaults to ``Release Pending`` (marking "verified" issues).

Configuration example (GSS authentication)::

[issues]
Expand Down Expand Up @@ -104,6 +108,8 @@
# Enable ssl verify
SSL_VERIFY = True

# State we are interested in
DEFAULT_TRANSITION_TO = "Release Pending"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Issue Investigator
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -261,10 +267,30 @@ def fetch(self):
self.stats = Issue.search(query, stats=self)


class JiraTransition(Stats):
""" Issues transitioned to specified state """

def fetch(self):
log.info("Searching for issues transitioned to '{0}' by '{1}'".format(
self.parent.transition_to, self.user.login or self.user.email
))
query = (
"status changed to '{0}' and status changed by '{1}' "
"after {2} before {3}".format(
self.parent.transition_to,
self.user.login or self.user.email,
self.options.since,
self.options.until))
if self.parent.project:
query = query + " AND project = '{0}'".format(
self.parent.project)
self.stats = Issue.search(query, stats=self)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Stats Group
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


class JiraStats(StatsGroup):
""" Jira stats """

Expand Down Expand Up @@ -369,6 +395,10 @@ def __init__(self, option, name=None, parent=None, user=None):

# Check for custom prefix
self.prefix = config["prefix"] if "prefix" in config else None

# State transition to count
self.transition_to = config.get("transition_to", DEFAULT_TRANSITION_TO)

# Create the list of stats
self.stats = [
JiraCreated(
Expand All @@ -380,6 +410,9 @@ def __init__(self, option, name=None, parent=None, user=None):
JiraResolved(
option=option + "-resolved", parent=self,
name="Issues resolved in {0}".format(option)),
JiraTransition(
option=option + "-transitioned", parent=self,
name="Issues transitioned in {0}".format(option)),
]

@property
Expand Down