Skip to content

Commit

Permalink
feat: use is_boot function in api
Browse files Browse the repository at this point in the history
- tree details
- tree commits history
- hardware details

Part of #741
  • Loading branch information
Francisco2002 committed Jan 15, 2025
1 parent 9c00fcc commit ad84095
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
5 changes: 2 additions & 3 deletions backend/kernelCI_app/helpers/treeDetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
env_misc_value_or_default,
)
from kernelCI_app.cache import getQueryCache, setQueryCache
from kernelCI_app.utils import is_boot
from django.db import connection


Expand Down Expand Up @@ -231,9 +232,7 @@ def get_hardware_filter(row_data: dict) -> Any:

def is_test_boots_test(row_data: dict) -> bool:
test_path = row_data["test_path"]
if test_path.startswith("boot"):
return True
return False
return is_boot(test_path)


def get_build(row_data: dict) -> dict:
Expand Down
15 changes: 8 additions & 7 deletions backend/kernelCI_app/views/hardwareDetailsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
from kernelCI_app.cache import getQueryCache, setQueryCache
from kernelCI_app.viewCommon import create_details_build_summary
from kernelCI_app.models import Tests
from kernelCI_app.utils import create_issue, extract_error_message
from kernelCI_app.utils import (
create_issue,
extract_error_message,
is_boot
)
from django.views.decorators.csrf import csrf_exempt
from kernelCI_app.helpers.trees import get_tree_heads
from kernelCI_app.helpers.filters import UNKNOWN_STRING, FilterParams
Expand Down Expand Up @@ -100,10 +104,6 @@ def get_history(record: Dict):
}


def is_boot(record: Dict) -> bool:
return record["path"] == "boot" or record["path"].startswith("boot.")


def get_record_tree(record: Dict, selected_trees: List) -> Optional[Dict]:
for tree in selected_trees:
if (
Expand Down Expand Up @@ -386,7 +386,7 @@ def sanitize_records(self, records, trees: List, is_all_selected: bool):
compatibles.update(record["environment_compatible"])

tree_index = current_tree["index"]
is_record_boot = is_boot(record)
is_record_boot = is_boot(record['path'])
# TODO -> Unify with tree_status_key, be careful with the pluralization
test_filter_key = "boot" if is_record_boot else "test"

Expand All @@ -411,7 +411,8 @@ def sanitize_records(self, records, trees: List, is_all_selected: bool):
continue

should_process_test = (
self.test_in_filter(test_filter_key, record)
record['id'] is not None
and self.test_in_filter(test_filter_key, record)
and record["id"] not in processed_tests
)

Expand Down
11 changes: 5 additions & 6 deletions backend/kernelCI_app/views/treeCommitsHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
build_misc_value_or_default,
env_misc_value_or_default,
)
from kernelCI_app.utils import getErrorResponseBody
from kernelCI_app.utils import getErrorResponseBody, is_boot
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
Expand Down Expand Up @@ -225,10 +225,6 @@ def _process_tests(self, row: Dict) -> None:
incident_test_id = row["incidents_test_id"]
build_valid = row["build_valid"]

is_boot = test_path is not None and test_path.startswith(
"boot"
)

commit_hash = row["git_commit_hash"]

if issue_id is None and (
Expand All @@ -237,7 +233,10 @@ def _process_tests(self, row: Dict) -> None:
):
issue_id = UNKNOWN_STRING

if is_boot:
if test_id is None:
return

if is_boot(test_path):
self._process_boots_count(
test_id=test_id,
test_status=test_status,
Expand Down

0 comments on commit ad84095

Please sign in to comment.