From 92c5e821d222a4b7f4232d814c44ab6cf54fd838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zachar?= Date: Thu, 4 Jan 2024 16:54:15 +0100 Subject: [PATCH 1/3] jira: Count verified issues --- did/plugins/jira.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/did/plugins/jira.py b/did/plugins/jira.py index c9098864..a2b7edde 100644 --- a/did/plugins/jira.py +++ b/did/plugins/jira.py @@ -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. +verified_status + Name of the issue status which marks it verified. + Defaults to ``Release Pending``. + Configuration example (GSS authentication):: [issues] @@ -104,6 +108,8 @@ # Enable ssl verify SSL_VERIFY = True +# State marking verified issues +DEFAULT_VERIFIED_STATUS = "Release Pending" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Issue Investigator # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -261,10 +267,30 @@ def fetch(self): self.stats = Issue.search(query, stats=self) +class JiraVerified(Stats): + """ Verified issues """ + + def fetch(self): + log.info("Searching for issues transitioned to {0} by {1}".format( + self.parent.verified_status, self.user.login or self.user.email + )) + query = ( + "status changed to '{0}' and status changed by {1} " + "after {2} before {3}".format( + self.parent.verified_status, + 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 """ @@ -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 marking Verified jira + self.verified_status = config.get("verified_status", DEFAULT_VERIFIED_STATUS) + # Create the list of stats self.stats = [ JiraCreated( @@ -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)), + JiraVerified( + option=option + "-verified", parent=self, + name="Issues verified in {0}".format(option)), ] @property From d33950435158c8fd3f05ff9584033bd9ab2c67e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Mon, 8 Jan 2024 16:18:59 +0100 Subject: [PATCH 2/3] squash: Quote user login in the query --- did/plugins/jira.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/did/plugins/jira.py b/did/plugins/jira.py index a2b7edde..ee36ddb3 100644 --- a/did/plugins/jira.py +++ b/did/plugins/jira.py @@ -275,7 +275,7 @@ def fetch(self): self.parent.verified_status, self.user.login or self.user.email )) query = ( - "status changed to '{0}' and status changed by {1} " + "status changed to '{0}' and status changed by '{1}' " "after {2} before {3}".format( self.parent.verified_status, self.user.login or self.user.email, From e1472f184261164b87cebbb9e07ac41428369e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zachar?= Date: Thu, 1 Feb 2024 09:35:30 +0100 Subject: [PATCH 3/3] sq: rename option/plugin --- did/plugins/jira.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/did/plugins/jira.py b/did/plugins/jira.py index ee36ddb3..b8c27793 100644 --- a/did/plugins/jira.py +++ b/did/plugins/jira.py @@ -29,9 +29,9 @@ Name of the token to check for expiration in ``token_expiration`` days. This has to match the name as seen in your Jira profile. -verified_status - Name of the issue status which marks it verified. - Defaults to ``Release Pending``. +transition_to + Name of the issue status we want to report transitions to. + Defaults to ``Release Pending`` (marking "verified" issues). Configuration example (GSS authentication):: @@ -108,8 +108,8 @@ # Enable ssl verify SSL_VERIFY = True -# State marking verified issues -DEFAULT_VERIFIED_STATUS = "Release Pending" +# State we are interested in +DEFAULT_TRANSITION_TO = "Release Pending" # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Issue Investigator # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -267,17 +267,17 @@ def fetch(self): self.stats = Issue.search(query, stats=self) -class JiraVerified(Stats): - """ Verified issues """ +class JiraTransition(Stats): + """ Issues transitioned to specified state """ def fetch(self): - log.info("Searching for issues transitioned to {0} by {1}".format( - self.parent.verified_status, self.user.login or self.user.email + 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.verified_status, + self.parent.transition_to, self.user.login or self.user.email, self.options.since, self.options.until)) @@ -396,8 +396,8 @@ 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 marking Verified jira - self.verified_status = config.get("verified_status", DEFAULT_VERIFIED_STATUS) + # State transition to count + self.transition_to = config.get("transition_to", DEFAULT_TRANSITION_TO) # Create the list of stats self.stats = [ @@ -410,9 +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)), - JiraVerified( - option=option + "-verified", parent=self, - name="Issues verified in {0}".format(option)), + JiraTransition( + option=option + "-transitioned", parent=self, + name="Issues transitioned in {0}".format(option)), ] @property