Skip to content

Commit ab917f1

Browse files
committed
Filter out Copr builds without SRPM in SQL
In addition to pagination slicing, the CoprBuildsList class uses Python code to filter out Copr builds that are waiting for an SRPM or whose SRPM build failed. This causes that the API in some cases can return fewer items than the user requested. Moving the filter into SQL resolves the problem. The SQL filter relies on the fact that the build_id field is NULL until the build is actually created by submitting to Copr. Resolves: #2505
1 parent aa1ffde commit ab917f1

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packit_service/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,12 @@ def get_merged_chroots(
22382238
"packit_id_per_chroot",
22392239
),
22402240
)
2241+
.filter(
2242+
# Exclude builds without build_id - these are builds waiting for SRPM
2243+
# or where SRPM build failed, so technically they are not actual Copr
2244+
# builds yet.
2245+
CoprBuildTargetModel.build_id.isnot(None),
2246+
)
22412247
.group_by(
22422248
CoprBuildTargetModel.build_id,
22432249
) # Group by identical element(s)

packit_service/service/api/copr_builds.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from flask_restx import Namespace, Resource
88

99
from packit_service.models import (
10-
BuildStatus,
1110
CoprBuildGroupModel,
1211
CoprBuildTargetModel,
1312
optional_timestamp,
@@ -35,15 +34,6 @@ def get(self):
3534
first, last = indices()
3635
for build in CoprBuildTargetModel.get_merged_chroots(first, last):
3736
build_info = CoprBuildTargetModel.get_by_build_id(build.build_id, None)
38-
if build_info.status == BuildStatus.waiting_for_srpm:
39-
continue
40-
if (
41-
build_info.status == BuildStatus.failure
42-
and not build_info.build_start_time
43-
and not build_info.build_logs_url
44-
):
45-
# SRPM build failed, it doesn't make sense to list this build
46-
continue
4737
project_info = build_info.get_project()
4838
build_dict = {
4939
"packit_id": build_info.id,

0 commit comments

Comments
 (0)