Skip to content

Commit

Permalink
feat(hardware-details): add platform support
Browse files Browse the repository at this point in the history
- Added `models.Q` to filter queries by `environment_misc__platform`
- Wrapped `_sanitize_records` and `_format_processing_for_response` in try block
- Updated error response to use `e.json()` in `HardwareDetailsSummaryView`
- Added check for `summaryResponse.data.common.compatibles` length in `HardwareDetails.tsx`
  • Loading branch information
WilsonNet committed Feb 4, 2025
1 parent 58eb284 commit ac8eadb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 28 deletions.
7 changes: 5 additions & 2 deletions backend/kernelCI_app/helpers/hardwareDetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
extract_error_message,
is_boot,
)
from django.db import models
from pydantic import ValidationError
from django.db.models import Subquery
from kernelCI_app.typeModels.hardwareDetails import (
Expand Down Expand Up @@ -102,7 +103,8 @@ def get_hardware_trees_data(

trees_query_set = (
Tests.objects.filter(
environment_compatible__contains=[hardware_id],
models.Q(environment_compatible__contains=[hardware_id])
| models.Q(environment_misc__platform=hardware_id),
origin=origin,
build__checkout__start_time__lte=end_datetime,
build__checkout__start_time__gte=start_datetime,
Expand Down Expand Up @@ -268,10 +270,11 @@ def query_records(
"build__incidents__issue__id",
"build__incidents__issue__version",
).filter(
models.Q(environment_compatible__contains=[hardware_id])
| models.Q(environment_misc__platform=hardware_id),
start_time__gte=start_date,
start_time__lte=end_date,
build__checkout__origin=origin,
environment_compatible__contains=[hardware_id],
# TODO Treat commit_hash collision (it can happen between repos)
build__checkout__git_commit_hash__in=commit_hashes,
)
Expand Down
5 changes: 3 additions & 2 deletions backend/kernelCI_app/typeModels/hardwareDetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)

from kernelCI_app.typeModels.databases import (
Issue__Id,
StatusValues,
Checkout__TreeName,
Checkout__GitRepositoryBranch,
Expand Down Expand Up @@ -94,8 +95,8 @@ class HardwareTestHistoryItem(TestHistoryItem):


class HardwareBuildHistoryItem(BuildHistoryItem):
tree_name: Optional[str]
issue_id: Optional[str]
tree_name: Optional[Checkout__TreeName]
issue_id: Optional[Issue__Id]
issue_version: Optional[Issue__Version]


Expand Down
26 changes: 13 additions & 13 deletions backend/kernelCI_app/views/hardwareDetailsSummaryView.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,22 @@ def post(self, request, hardware_id) -> Response:

is_all_selected = len(self.selected_commits) == 0

self._sanitize_records(records, trees_with_selected_commits, is_all_selected)
try:
self._sanitize_records(records, trees_with_selected_commits, is_all_selected)

self._format_processing_for_response(hardware_id=hardware_id)
self._format_processing_for_response(hardware_id=hardware_id)

get_filter_options(
instance=self,
records=records,
selected_trees=trees_with_selected_commits,
is_all_selected=is_all_selected,
)
get_filter_options(
instance=self,
records=records,
selected_trees=trees_with_selected_commits,
is_all_selected=is_all_selected,
)

set_trees_status_summary(
trees=trees, tree_status_summary=self.tree_status_summary
)
set_trees_status_summary(
trees=trees, tree_status_summary=self.tree_status_summary
)

try:
valid_response = HardwareDetailsSummaryResponse(
summary=Summary(
builds=self.builds_summary,
Expand Down Expand Up @@ -300,6 +300,6 @@ def post(self, request, hardware_id) -> Response:
),
)
except ValidationError as e:
return Response(data=e.errors(), status=HTTPStatus.INTERNAL_SERVER_ERROR)
return Response(data=e.json(), status=HTTPStatus.INTERNAL_SERVER_ERROR)

return Response(data=valid_response.model_dump(), status=HTTPStatus.OK)
23 changes: 12 additions & 11 deletions dashboard/src/pages/hardwareDetails/HardwareDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,18 @@ function HardwareDetails(): JSX.Element {
updateTreeFilters={updateTreeFilters}
setTreeIndexesLength={setTreeIndexesLength}
/>
{summaryResponse.data && (
<div className="mt-5">
<MemoizedCompatibleHardware
title={
<FormattedMessage id="hardwareDetails.compatibles" />
}
compatibles={summaryResponse.data.common.compatibles}
diffFilter={diffFilter}
/>
</div>
)}
{summaryResponse.data &&
summaryResponse.data.common.compatibles.length > 0 && (
<div className="mt-5">
<MemoizedCompatibleHardware
title={
<FormattedMessage id="hardwareDetails.compatibles" />
}
compatibles={summaryResponse.data.common.compatibles}
diffFilter={diffFilter}
/>
</div>
)}
</>
)}
<div className="flex flex-col pb-2">
Expand Down

0 comments on commit ac8eadb

Please sign in to comment.