Skip to content

Commit f683ae8

Browse files
committed
fixup! feat: Change queries to use lab column information
Enforce the lab FK db_constraint on builds and tests, drop the unused lab_id from the build tests response, and fix the tree query lab TODO. Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
1 parent 4c9cf04 commit f683ae8

7 files changed

Lines changed: 3 additions & 15 deletions

File tree

backend/kernelCI_app/migrations/0019_labs_builds_lab_tests_lab.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class Migration(migrations.Migration):
2424
model_name="builds",
2525
name="lab",
2626
field=models.ForeignKey(
27-
db_constraint=False,
2827
null=True,
2928
on_delete=django.db.models.deletion.DO_NOTHING,
3029
to="kernelCI_app.labs",
@@ -34,7 +33,6 @@ class Migration(migrations.Migration):
3433
model_name="tests",
3534
name="lab",
3635
field=models.ForeignKey(
37-
db_constraint=False,
3836
null=True,
3937
on_delete=django.db.models.deletion.DO_NOTHING,
4038
to="kernelCI_app.labs",

backend/kernelCI_app/models.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ class Builds(models.Model):
132132
log_url = models.TextField(blank=True, null=True)
133133
log_excerpt = models.CharField(max_length=16384, blank=True, null=True)
134134
misc = models.JSONField(blank=True, null=True)
135-
lab = models.ForeignKey(
136-
Labs, db_constraint=False, null=True, on_delete=models.DO_NOTHING
137-
)
135+
lab = models.ForeignKey(Labs, null=True, on_delete=models.DO_NOTHING)
138136
status = models.CharField(
139137
max_length=10, choices=StatusChoices.choices, blank=True, null=True
140138
)
@@ -193,9 +191,7 @@ class UnitPrefix(models.TextChoices):
193191
input_files = models.JSONField(blank=True, null=True)
194192
output_files = models.JSONField(blank=True, null=True)
195193
misc = models.JSONField(blank=True, null=True)
196-
lab = models.ForeignKey(
197-
Labs, db_constraint=False, null=True, on_delete=models.DO_NOTHING
198-
)
194+
lab = models.ForeignKey(Labs, null=True, on_delete=models.DO_NOTHING)
199195
number_value = models.FloatField(blank=True, null=True)
200196
environment_compatible = ArrayField(models.TextField(), blank=True, null=True)
201197
number_prefix = models.CharField(

backend/kernelCI_app/queries/build.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def get_build_tests(build_id: str) -> Optional[list[dict]]:
6060
tests.environment_compatible,
6161
tests.environment_misc,
6262
builds.status AS build__status,
63-
tests.lab_id,
6463
-- TODO remove misc->>'runtime' fallback after lab backfill
6564
COALESCE(labs.name, tests.misc->>'runtime') AS lab
6665
FROM tests

backend/kernelCI_app/queries/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def get_tree_details_data(
227227
tests.number_value AS tests_number_value,
228228
tests.misc AS tests_misc,
229229
tests.environment_compatible AS tests_environment_compatible,
230-
-- TODO remove misc->>'lab' fallback after lab backfill
230+
-- TODO remove misc->>'runtime' fallback after lab backfill
231231
COALESCE(test_labs.name, tests.misc ->> 'runtime') AS tests_lab,
232232
builds_filter.*,
233233
incidents.id AS incidents_id,

backend/kernelCI_app/tests/unitTests/queries/build_test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def test_get_build_tests_success(self, mock_connection):
3838
["hardware1"],
3939
{"platform": "x86_64"},
4040
"PASS",
41-
1,
4241
"lab-a",
4342
)
4443
]
@@ -51,7 +50,6 @@ def test_get_build_tests_success(self, mock_connection):
5150
("environment_compatible",),
5251
("environment_misc",),
5352
("build__status",),
54-
("lab_id",),
5553
("lab",),
5654
]
5755

@@ -67,7 +65,6 @@ def test_get_build_tests_success(self, mock_connection):
6765
"environment_compatible": ["hardware1"],
6866
"environment_misc": {"platform": "x86_64"},
6967
"build__status": "PASS",
70-
"lab_id": 1,
7168
"lab": "lab-a",
7269
}
7370
]

backend/kernelCI_app/tests/unitTests/views/fixtures/build_data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,5 @@
4747
"start_time": datetime.now(),
4848
"environment_compatible": ["test_environment_compatible"],
4949
"environment_misc": {"test_environment_misc": "test_environment_misc"},
50-
"lab_id": 1,
5150
"lab": "test_lab",
5251
}

backend/kernelCI_app/typeModels/buildDetails.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class BuildTestItem(BaseModel):
5353
start_time: Test__StartTime
5454
environment_compatible: Test__EnvironmentCompatible
5555
environment_misc: Test__EnvironmentMisc
56-
lab_id: Optional[int]
5756
lab: Optional[str]
5857

5958

0 commit comments

Comments
 (0)