Skip to content

Commit

Permalink
fix: server error in test of microsoft origin
Browse files Browse the repository at this point in the history
- environment misc platform is null for the test

Close #1040
  • Loading branch information
Francisco2002 committed Mar 6, 2025
1 parent 0c1bbe8 commit 3c2a351
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
34 changes: 18 additions & 16 deletions backend/kernelCI_app/queries/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ def get_test_status_history(
platform: str,
current_test_timestamp: datetime,
):
return (
Tests.objects.values(
"field_timestamp",
"id",
"status",
"build__checkout__git_commit_hash",
)
.filter(
path=path,
build__checkout__origin=origin,
build__checkout__git_repository_url=git_repository_url,
build__checkout__git_repository_branch=git_repository_branch,
environment_misc__platform=platform,
field_timestamp__lte=current_test_timestamp,
)
.order_by("-field_timestamp")[:10]
query = Tests.objects.values(
"field_timestamp",
"id",
"status",
"build__checkout__git_commit_hash",
).filter(
path=path,
build__checkout__origin=origin,
build__checkout__git_repository_url=git_repository_url,
build__checkout__git_repository_branch=git_repository_branch,
field_timestamp__lte=current_test_timestamp,
)

if platform is None:
query = query.filter(environment_misc__platform__isnull=True)
else:
query = query.filter(environment_misc__platform=platform)

return query.order_by("-field_timestamp")[:10]
2 changes: 1 addition & 1 deletion backend/kernelCI_app/typeModels/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class EnvironmentMisc(BaseModel):
type Test__Path = Optional[str]
type Test__StartTime = Optional[datetime]
type Test__EnvironmentCompatible = Optional[List[str]]
type Test__EnvironmentMisc = Optional[EnvironmentMisc]
type Test__EnvironmentMisc = Optional[Jsonb]
type Test__LogExcerpt = Optional[str]
type Test__LogUrl = Optional[str]
type Test__Misc = Optional[Jsonb]
Expand Down
4 changes: 3 additions & 1 deletion backend/kernelCI_app/views/testDetailsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ def get(self, _request, test_id: str) -> Response:
error_message="Test not found", status_code=HTTPStatus.OK
)

platform = response["environment_misc"].get("platform")

status_history_response = get_test_status_history(
path=response["path"],
origin=response["build__checkout__origin"],
git_repository_url=response["build__checkout__git_repository_url"],
git_repository_branch=response["build__checkout__git_repository_branch"],
platform=response["environment_misc"]["platform"],
platform=platform,
current_test_timestamp=response["field_timestamp"],
)

Expand Down

0 comments on commit 3c2a351

Please sign in to comment.