Skip to content

Commit

Permalink
Add jira qa needed data
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelrios committed Jul 19, 2024
1 parent 68e7672 commit 9fe7756
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/staging-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:

- name: Jira query
run: python ./__main__.py --report-type jira-qa-requests
- name: Jira query
run: python ./__main__.py --report-type jira-qa-needed
- name: Set job log URL
if: always()
run: echo "JOB_LOG_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
Expand Down
4 changes: 3 additions & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def parse_args(cmdln_args):

def main():
args = parse_args(sys.argv[1:])

if args.report_type == 'test-case-coverage':
h = TestRailClient()
h.data_pump(args.project.lower())
Expand All @@ -56,6 +55,9 @@ def main():
if args.report_type == 'jira-qa-requests':
h = JiraClient()
h.jira_qa_requests()
if args.report_type == 'jira-qa-needed':
h = JiraClient()
h.jira_qa_needed()


if __name__ == '__main__':
Expand Down
4 changes: 4 additions & 0 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class ReportJiraQARequests(Base):
__table__ = Table('report_jira_qa_requests', Base.metadata, autoload=True) # noqa


class ReportJiraQANeeded(Base):
__table__ = Table('report_jira_qa_needed', Base.metadata, autoload=True) # noqa


class Database:

def __init__(self):
Expand Down
39 changes: 37 additions & 2 deletions jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
from lib.jira_conn import JiraAPIClient
from database import (
Database,
ReportJiraQARequests
ReportJiraQARequests,
ReportJiraQANeeded
)
from utils.datetime_utils import DatetimeUtils as dt
from utils.constants import FILTER_ID_ALL_REQUESTS_2022, MAX_RESULT

from utils.constants import FILTER_ID_QA_NEEDED_iOS

# JQL query All QA Requests since 2022 filter_id: 13856
# Extra fields needed
Expand Down Expand Up @@ -44,6 +45,10 @@ def filters(self):

return self.client.get_search(query)

def filter_qa_needed(self):
query = JQL_QUERY + FILTER_ID_QA_NEEDED_iOS + '&' + MAX_RESULT
return self.client.get_search(query)


class JiraClient(Jira):
def __init__(self):
Expand All @@ -62,6 +67,13 @@ def jira_qa_requests(self):

self.db.report_jira_qa_requests_insert(data_frame)

def jira_qa_needed(self):
payload = self.filter_qa_needed()
data_frame = self.db.report_jira_qa_needed(payload)
print(data_frame)

self.db.report_jira_qa_needed_instert(data_frame)


class DatabaseJira(Database):

Expand Down Expand Up @@ -136,3 +148,26 @@ def report_jira_qa_requests_insert(self, payload):
jira_labels=row['jira_labels'])
self.session.add(report)
self.session.commit()

def report_jira_qa_needed(self, payload):
# Normalize the JSON data
df = pd.json_normalize(payload, sep='_')
total_rows = len(df)

# Join list of labels into a single string
jira_labels = df['fields_labels'] = df['fields_labels'].apply(lambda x: ','.join(x) if isinstance(x, list) else x) # noqa
# Calcule the Nightly Verified label
verified_nightly_count = jira_labels.str.contains('verified', case=False, na=False).sum() # noqa

not_verified_count = total_rows - verified_nightly_count

data = [total_rows, not_verified_count, verified_nightly_count]
return data

def report_jira_qa_needed_instert(self, payload):
report = ReportJiraQANeeded(jira_total_qa_needed=payload[0],
jira_qa_needed_not_verified=payload[1],
jira_qa_needed_verified_nightly=payload[2])

self.session.add(report)
self.session.commit()
2 changes: 1 addition & 1 deletion lib/jira_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def get_search(self, query):

def __send_request(self, method, query):
url = self.__url + '?' + query

# Store all results
all_results = []
params = {}
Expand All @@ -55,6 +54,7 @@ def __send_request(self, method, query):
params=params)

data = response.json()

all_results.extend(data['issues'])
if total is None:
total = data['total']
Expand Down
6 changes: 5 additions & 1 deletion utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
'test-case-coverage',
'test-run-counts',
'issue-regression',
'jira-qa-requests'
'jira-qa-requests',
'jira-qa-needed'
]

# JQL query All QA Requests since 2022 filter_id: 13856
FILTER_ID_ALL_REQUESTS_2022 = "13856"
MAX_RESULT = "maxResults=100"

# JQL query All QA Needed iOS filter_id: 13789
FILTER_ID_QA_NEEDED_iOS = "13789"

0 comments on commit 9fe7756

Please sign in to comment.