Skip to content

Commit

Permalink
Enable printing the database while limiting it to a specific library
Browse files Browse the repository at this point in the history
  • Loading branch information
tomrittervg committed Mar 19, 2024
1 parent 78a8ed3 commit 44a25f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def run(self, library_filter=""):
'LoggingProvider': SimpleLogger({'local': True, 'level': 5})
})
try:
db.print()
db.print(args.library_filter)
except Exception as e:
print("Error printing database:")
print(e)
Expand Down
16 changes: 12 additions & 4 deletions components/dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def get_all_jobs_for_library(self, library, jobtype):
jobs = self.db.get_all_jobs_for_library(library)
return [j for j in jobs if j.type == jobtype]

def get_all_jobs_for_library_by_name(self, library_name):
jobs = self.db.get_all_jobs()
return [j for j in jobs if library_name in j.library_shortname]

def get_job(self, library, new_version):
return self.db.get_job(library, new_version)

Expand Down Expand Up @@ -83,7 +87,7 @@ def add_try_run(self, existing_job, try_revision, try_run_type):
def add_phab_revision(self, existing_job, phab_revision, phab_revision_type):
return self.db.add_phab_revision(existing_job, phab_revision, phab_revision_type)

def print(self):
def print(self, library_filter=None):
def get_column_widths(objects, columns):
widths = []

Expand Down Expand Up @@ -134,10 +138,14 @@ def print_objects(name, objects, columns):

job_columns = ['id', 'type', 'created', 'library_shortname', 'version',
'status', 'outcome', 'relinquished', 'bugzilla_id', 'ff_versions']
print_objects("JOBS", self.get_all_jobs(), job_columns)
if library_filter:
jobs = self.get_all_jobs_for_library_by_name(library_filter)
else:
jobs = self.get_all_jobs()
print_objects("JOBS", jobs, job_columns)

try_run_columns = ['id', 'revision', 'job_id', 'purpose']
print_objects("TRY RUNS", self.get_all_try_runs(), try_run_columns)
print_objects("TRY RUNS", [t for t in self.get_all_try_runs() if t.job_id in [j.id for j in jobs]], try_run_columns)

phab_revision_columns = ['id', 'revision', 'job_id', 'purpose']
print_objects("PHABRICATOR REVISIONS", self.get_all_phabricator_revisions(), phab_revision_columns)
print_objects("PHABRICATOR REVISIONS", [r for r in self.get_all_phabricator_revisions() if r.job_id in [j.id for j in jobs]], phab_revision_columns)

0 comments on commit 44a25f4

Please sign in to comment.