Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelrios committed Oct 2, 2024
1 parent 5435007 commit eb6b661
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 38 deletions.
1 change: 1 addition & 0 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ def main():
h = BugzillaClient()
h.bugzilla_qe_verify()


if __name__ == '__main__':
main()
75 changes: 38 additions & 37 deletions bugz.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
import os
import sys
import re
import json

import pandas as pd
import bugzilla

from lib.bugzilla_conn import BugzillaAPIClient
from utils.datetime_utils import DatetimeUtils as dt

from datetime import datetime

from database import (
Database,
ReportBugzillaQEVerifyCount,
ReportBugzillaQENeeded
)


PRODUCTS = ["Fenix", "Focus", "GeckoView"]
FIELDS = ["id", "summary", "flags", "severity", "priority", "status", "resolution"]
FIELDS = ["id", "summary", "flags", "severity",
"priority", "status", "resolution"]


class Bugz:
Expand All @@ -43,6 +34,7 @@ def get_query_from_url(self, url: str) -> dict:
query = self.conn.bz_client.url_to_query(url)
return query


class BugzillaHelper:
def __init__(self) -> None:
self.bugzilla = Bugz()
Expand All @@ -63,6 +55,7 @@ def get_query_from_url(self, url: str) -> dict:
"""Get a query from a Bugzilla URL."""
return self.bugzilla.get_query_from_url(url)


class BugzillaClient(Bugz):
def __init__(self):
super().__init__()
Expand All @@ -79,32 +72,33 @@ def bugzilla_query(self):
bugs = self.BugzillaHelperClient.query(query)

for bug in bugs:
bug_ = [bug.id, bug.summary, bug.flags, bug.severity, bug.priority, bug.status, bug.resolution]
bug_ = [bug.id, bug.summary, bug.flags,
bug.severity, bug.priority, bug.status, bug.resolution]
allBugs.append(bug_)

return allBugs

def bugzilla_query_qe_verify(self):
qe_bugs = []
search_criteria = {'name': 'qe-verify', 'status': '+'}

payload = self.bugzilla_query()

for bug in payload:
result = any(self.contains_criteria(entry, search_criteria) for entry in bug[2])
if result == True:
result = any(self.contains_criteria(entry, search_criteria) for entry in bug[2]) # noqa
if result:
qe_bugs.append(bug)

return qe_bugs

def bugzilla_query_severity(self):
payload = self.bugzilla_query()
# payload = self.bugzilla_query()

# TBD to get all NEW bugs
return

def bugzilla_qe_verify(self):
payload=self.bugzilla_query_qe_verify()
payload = self.bugzilla_query_qe_verify()

rows = []
for entry in payload:
Expand All @@ -117,11 +111,17 @@ def bugzilla_qe_verify(self):
# If there are additional fields (sub-entry), iterate over them
if entry[2]:
for sub_entry in entry[2]:
row = {"bug_id": bug_id, "description": description, **sub_entry, "severity": severity, "priority": priority, "bug_status": status, "resolution": resolution}
row = {"bug_id": bug_id, "description": description,
**sub_entry, "severity": severity,
"priority": priority,
"bug_status": status, "resolution": resolution}
rows.append(row)
else:
# If no sub-entry, just add the bug_id description
row = {"bug_id": bug_id, "description": description, "severity": severity, "priority": priority, "priority": priority, "bug_status": status, "resolution": resolution}
row = {"bug_id": bug_id, "description": description,
"severity": severity, "priority": priority,
"priority": priority, "bug_status": status,
"resolution": resolution}
rows.append(row)

# Create the DataFrame
Expand All @@ -135,7 +135,7 @@ def bugzilla_qe_verify(self):

data_frame = self.db.report_bugzilla_qa_needed(df_cleaned)
self.db.report_bugzilla_qa_needed_insert(data_frame)

qe_needed_count = self.db.report_bugzilla_qa_needed_count(data_frame)
self.db.report_bugzilla_qa_needed_count_insert(qe_needed_count)

Expand All @@ -160,31 +160,31 @@ def report_bugzilla_qa_needed(self, payload):
'priority': 'bugzilla_bug_priority',
'bug_status': 'bugzilla_bug_status',
'resolution': 'bugzilla_bug_resolution'

}

# Select specific columns
df = payload[selected_columns.keys()]

# Rename columns
df = df.rename(columns=selected_columns)
return df

def report_bugzilla_qa_needed_insert(self, payload):
for index, row in payload.iterrows():
print(row)
report = ReportBugzillaQENeeded(bugzilla_key=row['bugzilla_key'],
bugzilla_summary=row['bugzilla_summary'],
buzilla_modified_at=row['bugzilla_modified_at'].date(),
bugzilla_tag_name=row['bugzilla_tag_name'],
bugzilla_created_at=row['bugzilla_created_at'].date(),
bugzilla_tag_status=row['bugzilla_tag_status'],
bugzilla_tag_setter=row['bugzilla_tag_setter'],
bugzilla_bug_severity=row['bugzilla_bug_severity'],
bugzilla_bug_priority=row['bugzilla_bug_priority'],
bugzilla_bug_status=row['bugzilla_bug_status'],
bugzilla_bug_resolution=row['bugzilla_bug_resolution']
)
report = ReportBugzillaQENeeded(
bugzilla_key=row['bugzilla_key'],
bugzilla_summary=row['bugzilla_summary'],
buzilla_modified_at=row['bugzilla_modified_at'].date(),
bugzilla_tag_name=row['bugzilla_tag_name'],
bugzilla_created_at=row['bugzilla_created_at'].date(),
bugzilla_tag_status=row['bugzilla_tag_status'],
bugzilla_tag_setter=row['bugzilla_tag_setter'],
bugzilla_bug_severity=row['bugzilla_bug_severity'],
bugzilla_bug_priority=row['bugzilla_bug_priority'],
bugzilla_bug_status=row['bugzilla_bug_status'],
bugzilla_bug_resolution=row['bugzilla_bug_resolution']
)

self.session.add(report)
self.session.commit()
Expand All @@ -195,7 +195,8 @@ def report_bugzilla_qa_needed_count(self, payload):
return data

def report_bugzilla_qa_needed_count_insert(self, payload):
report = ReportBugzillaQEVerifyCount(bugzilla_total_qa_needed=payload[0])
report = ReportBugzillaQEVerifyCount(
bugzilla_total_qa_needed=payload[0])

self.session.add(report)
self.session.commit()
1 change: 1 addition & 0 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ReportJiraQANeeded(Base):
class ReportBugzillaQENeeded(Base):
__table__ = Table('report_bugzilla_qe_needed', Base.metadata, autoload=True) # noqa


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

Expand Down
2 changes: 1 addition & 1 deletion lib/bugzilla_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def bz_client(self, client: bugzilla.Bugzilla) -> None:
def __init__(self) -> None:
self.key = os.environ.get("BUGZILLA_API_KEY")
if not self.key:
raise Exception("Please set the BUGZILLA_API_KEY environment variable")
raise Exception("Missing BUGZILLA_API_KEY")
if self.key:
self.bz_client = bugzilla.Bugzilla(self.URL, api_key=self.key)

0 comments on commit eb6b661

Please sign in to comment.