Skip to content

Commit 9fe7756

Browse files
committed
Add jira qa needed data
1 parent 68e7672 commit 9fe7756

File tree

6 files changed

+52
-5
lines changed

6 files changed

+52
-5
lines changed

.github/workflows/staging-push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252

5353
- name: Jira query
5454
run: python ./__main__.py --report-type jira-qa-requests
55+
- name: Jira query
56+
run: python ./__main__.py --report-type jira-qa-needed
5557
- name: Set job log URL
5658
if: always()
5759
run: echo "JOB_LOG_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV

__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def parse_args(cmdln_args):
3737

3838
def main():
3939
args = parse_args(sys.argv[1:])
40-
4140
if args.report_type == 'test-case-coverage':
4241
h = TestRailClient()
4342
h.data_pump(args.project.lower())
@@ -56,6 +55,9 @@ def main():
5655
if args.report_type == 'jira-qa-requests':
5756
h = JiraClient()
5857
h.jira_qa_requests()
58+
if args.report_type == 'jira-qa-needed':
59+
h = JiraClient()
60+
h.jira_qa_needed()
5961

6062

6163
if __name__ == '__main__':

database.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class ReportJiraQARequests(Base):
3939
__table__ = Table('report_jira_qa_requests', Base.metadata, autoload=True) # noqa
4040

4141

42+
class ReportJiraQANeeded(Base):
43+
__table__ = Table('report_jira_qa_needed', Base.metadata, autoload=True) # noqa
44+
45+
4246
class Database:
4347

4448
def __init__(self):

jira.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from lib.jira_conn import JiraAPIClient
77
from database import (
88
Database,
9-
ReportJiraQARequests
9+
ReportJiraQARequests,
10+
ReportJiraQANeeded
1011
)
1112
from utils.datetime_utils import DatetimeUtils as dt
1213
from utils.constants import FILTER_ID_ALL_REQUESTS_2022, MAX_RESULT
13-
14+
from utils.constants import FILTER_ID_QA_NEEDED_iOS
1415

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

4546
return self.client.get_search(query)
4647

48+
def filter_qa_needed(self):
49+
query = JQL_QUERY + FILTER_ID_QA_NEEDED_iOS + '&' + MAX_RESULT
50+
return self.client.get_search(query)
51+
4752

4853
class JiraClient(Jira):
4954
def __init__(self):
@@ -62,6 +67,13 @@ def jira_qa_requests(self):
6267

6368
self.db.report_jira_qa_requests_insert(data_frame)
6469

70+
def jira_qa_needed(self):
71+
payload = self.filter_qa_needed()
72+
data_frame = self.db.report_jira_qa_needed(payload)
73+
print(data_frame)
74+
75+
self.db.report_jira_qa_needed_instert(data_frame)
76+
6577

6678
class DatabaseJira(Database):
6779

@@ -136,3 +148,26 @@ def report_jira_qa_requests_insert(self, payload):
136148
jira_labels=row['jira_labels'])
137149
self.session.add(report)
138150
self.session.commit()
151+
152+
def report_jira_qa_needed(self, payload):
153+
# Normalize the JSON data
154+
df = pd.json_normalize(payload, sep='_')
155+
total_rows = len(df)
156+
157+
# Join list of labels into a single string
158+
jira_labels = df['fields_labels'] = df['fields_labels'].apply(lambda x: ','.join(x) if isinstance(x, list) else x) # noqa
159+
# Calcule the Nightly Verified label
160+
verified_nightly_count = jira_labels.str.contains('verified', case=False, na=False).sum() # noqa
161+
162+
not_verified_count = total_rows - verified_nightly_count
163+
164+
data = [total_rows, not_verified_count, verified_nightly_count]
165+
return data
166+
167+
def report_jira_qa_needed_instert(self, payload):
168+
report = ReportJiraQANeeded(jira_total_qa_needed=payload[0],
169+
jira_qa_needed_not_verified=payload[1],
170+
jira_qa_needed_verified_nightly=payload[2])
171+
172+
self.session.add(report)
173+
self.session.commit()

lib/jira_conn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def get_search(self, query):
3434

3535
def __send_request(self, method, query):
3636
url = self.__url + '?' + query
37-
3837
# Store all results
3938
all_results = []
4039
params = {}
@@ -55,6 +54,7 @@ def __send_request(self, method, query):
5554
params=params)
5655

5756
data = response.json()
57+
5858
all_results.extend(data['issues'])
5959
if total is None:
6060
total = data['total']

utils/constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
'test-case-coverage',
1212
'test-run-counts',
1313
'issue-regression',
14-
'jira-qa-requests'
14+
'jira-qa-requests',
15+
'jira-qa-needed'
1516
]
1617

1718
# JQL query All QA Requests since 2022 filter_id: 13856
1819
FILTER_ID_ALL_REQUESTS_2022 = "13856"
1920
MAX_RESULT = "maxResults=100"
21+
22+
# JQL query All QA Needed iOS filter_id: 13789
23+
FILTER_ID_QA_NEEDED_iOS = "13789"

0 commit comments

Comments
 (0)