Skip to content

Commit

Permalink
Include trigger info in scans list API (#2624)
Browse files Browse the repository at this point in the history
Include trigger info in scans list API

Reviewed-by: Maja Massarini
  • Loading branch information
softwarefactory-project-zuul[bot] authored Nov 11, 2024
2 parents 74261a7 + bdcf571 commit bea3f49
Showing 1 changed file with 20 additions and 31 deletions.
51 changes: 20 additions & 31 deletions packit_service/service/api/osh_scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,9 @@ def get(self):
result = []

for scan in OSHScanModel.get_range(first, last):
update_dict = {
"packit_id": scan.id,
"task_id": scan.task_id,
"status": scan.status,
"url": scan.url,
"issues_added_url": scan.issues_added_url,
"issues_fixed_url": scan.issues_fixed_url,
"scan_results_url": scan.scan_results_url,
"copr_build_target_id": scan.copr_build_target_id,
"submitted_time": optional_timestamp(scan.submitted_time),
}

if project := scan.copr_build_target.get_project():
update_dict["project_url"] = project.project_url
update_dict["repo_namespace"] = project.namespace
update_dict["repo_name"] = project.repo_name

result.append(update_dict)
scan_dict = get_scan_info(scan)
scan_dict["packit_id"] = scan.id
result.append(scan_dict)

resp = response_maker(
result,
Expand All @@ -70,16 +55,20 @@ def get(self, id):
status=HTTPStatus.NOT_FOUND,
)

scan_dict = {
"task_id": scan.task_id,
"status": scan.status,
"url": scan.url,
"issues_added_url": scan.issues_added_url,
"issues_fixed_url": scan.issues_fixed_url,
"scan_results_url": scan.scan_results_url,
"copr_build_target_id": scan.copr_build_target_id,
"submitted_time": optional_timestamp(scan.submitted_time),
}

scan_dict.update(get_project_info_from_build(scan.copr_build_target))
return response_maker(scan_dict)
return response_maker(get_scan_info(scan))


def get_scan_info(scan: OSHScanModel) -> dict:
scan_dict = {
"task_id": scan.task_id,
"status": scan.status,
"url": scan.url,
"issues_added_url": scan.issues_added_url,
"issues_fixed_url": scan.issues_fixed_url,
"scan_results_url": scan.scan_results_url,
"copr_build_target_id": scan.copr_build_target_id,
"submitted_time": optional_timestamp(scan.submitted_time),
}

scan_dict.update(get_project_info_from_build(scan.copr_build_target))
return scan_dict

0 comments on commit bea3f49

Please sign in to comment.