Skip to content

Commit

Permalink
fix lint and polish
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelrios committed Jan 14, 2025
1 parent f8e0adc commit d6ff18b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main():
if args.report_type == 'jira-qa-requests':
h = JiraClient()
h.jira_qa_requests()
#h.jira_qa_requests_new_issue_types()
h.jira_qa_requests_new_issue_types()
if args.report_type == 'jira-qa-needed':
h = JiraClient()
h.jira_qa_needed()
Expand Down
1 change: 1 addition & 0 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ReportGithubIssues(Base):
class ReportJiraQARequests(Base):
__table__ = Table('report_jira_qa_requests', Base.metadata, autoload=True) # noqa


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

Expand Down
50 changes: 19 additions & 31 deletions jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,10 @@
ReportJIraQARequestsNewIssueType
)
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_ALL_REQUESTS_2022, FILTER_ID_NEW_ISSUE_TYPES, MAX_RESULT # noqa
from utils.constants import JQL_QUERY, STORY_POINTS, FIREFOX_RELEASE_TRAIN, ENGINEERING_TEAM, DEFAULT_COLUMNS, COLUMNS_ISSUE_TYPE, TESTED_TRAINS # noqa
from utils.constants import FILTER_ID_QA_NEEDED_iOS

# JQL query All QA Requests since 2022 filter_id: 13856
# Extra fields needed
STORY_POINTS = "customfield_10037"
FIREFOX_RELEASE_TRAIN = "customfield_10155"
ENGINEERING_TEAM = "customfield_10134"
DEFAULT_COLUMNS = "id,key,status,created,summary,labels,assignee"
DEFAULT_COLUMNS_ISSUE_TYPE = "id,key,status,created,summary,labels,assignee,issuetype,parent"
TESTED_TRAINS = "customfield_11930"

NEW_FILTER_ID = "14266"

JQL_QUERY = 'jql=filter='


class Jira:

Expand All @@ -36,7 +24,6 @@ def __init__(self):
self.client = JiraAPIClient(JIRA_HOST)
self.client.user = os.environ['JIRA_USER']
self.client.password = os.environ['JIRA_PASSWORD']

except KeyError:
print("ERROR: Missing jira env var")
sys.exit(1)
Expand All @@ -51,8 +38,9 @@ def filters(self):
return self.client.get_search(query)

def filters_new_issue_type(self):
query = JQL_QUERY + NEW_FILTER_ID + '&fields=' \
+ DEFAULT_COLUMNS_ISSUE_TYPE + ',' + STORY_POINTS + ',' \
query = JQL_QUERY + FILTER_ID_NEW_ISSUE_TYPES + '&fields=' \
+ DEFAULT_COLUMNS + COLUMNS_ISSUE_TYPE + ',' \
+ STORY_POINTS + ',' \
+ FIREFOX_RELEASE_TRAIN + ',' + TESTED_TRAINS + ',' \
+ ENGINEERING_TEAM + '&' + MAX_RESULT

Expand Down Expand Up @@ -87,7 +75,7 @@ def jira_qa_requests_new_issue_types(self):

self.db.qa_requests_delete()

data_frame = self.db.report_jira_qa_requests__new_issue_types_payload(payload)
data_frame = self.db.report_jira_qa_requests__new_issue_types_payload(payload) # noqa
print(data_frame)

self.db.report_jira_qa_requests_insert_new_issue_types(data_frame)
Expand Down Expand Up @@ -159,6 +147,7 @@ def report_jira_qa_requests_payload(self, payload):

def report_jira_qa_requests__new_issue_types_payload(self, payload):
# Normalize the JSON data
self.session.query(ReportJIraQARequestsNewIssueType).delete()
df = pd.json_normalize(payload, sep='_')

# Check if 'jira_assignee_username' exists
Expand All @@ -184,7 +173,7 @@ def report_jira_qa_requests__new_issue_types_payload(self, payload):
'fields_assignee_emailAddress': 'jira_assignee_username',
'fields_labels': 'jira_labels',
'fields_customfield_11930': 'jira_tested_train',
'fields_issuetype_name':'jira_issue_type',
'fields_issuetype_name': 'jira_issue_type',
'fields_parent_key': 'jira_parent_link'
}

Expand Down Expand Up @@ -230,18 +219,17 @@ def report_jira_qa_requests_insert_new_issue_types(self, payload):
for index, row in payload.iterrows():
print(row)
report = ReportJIraQARequestsNewIssueType(jira_key=row['jira_key'],
jira_created_at=row['jira_created_at'].date(), # noqa
jira_summary=row['jira_summary'], # noqa
jira_firefox_release_train=row['jira_firefox_release_train'], # noqa
jira_engineering_team=row['jira_engineering_team'], # noqa
jira_story_points=row['jira_story_points'], # noqa
jira_status=row['jira_status'], # noqa
jira_assignee_username=row['jira_assignee_username'], # noqa
jira_labels=row['jira_labels'],
jira_tested_train=row['jira_tested_train'],
jira_issue_type=row['jira_issue_type'],
jira_parent_link=row['jira_parent_link']
)
jira_created_at=row['jira_created_at'].date(), # noqa
jira_summary=row['jira_summary'], # noqa
jira_firefox_release_train=row['jira_firefox_release_train'], # noqa
jira_engineering_team=row['jira_engineering_team'], # noqa
jira_story_points=row['jira_story_points'], # noqa
jira_status=row['jira_status'], # noqa
jira_assignee_username=row['jira_assignee_username'], # noqa
jira_labels=row['jira_labels'], # noqa
jira_tested_train=row['jira_tested_train'], # noqa
jira_issue_type=row['jira_issue_type'], # noqa
jira_parent_link=row['jira_parent_link']) # noqa
self.session.add(report)
self.session.commit()

Expand Down
13 changes: 13 additions & 0 deletions utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,22 @@
FILTER_ID_ALL_REQUESTS_2022 = "13856"
MAX_RESULT = "maxResults=100"

# JQL query Requests, Internal Task, Sub-Task filter_id: 14323
FILTER_ID_NEW_ISSUE_TYPES = "14323"

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

# JQL Extra fields needed
JQL_QUERY = 'jql=filter='

STORY_POINTS = "customfield_10037"
FIREFOX_RELEASE_TRAIN = "customfield_10155"
ENGINEERING_TEAM = "customfield_10134"
DEFAULT_COLUMNS = "id,key,status,created,summary,labels,assignee"
COLUMNS_ISSUE_TYPE = ",issuetype,parent"
TESTED_TRAINS = "customfield_11930"

# Bugzilla queries
BUGZILLA_URL = "bugzilla.mozilla.org"
PRODUCTS = ["Fenix", "Focus", "GeckoView"]
Expand Down

0 comments on commit d6ff18b

Please sign in to comment.