Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show 'NULL' instead of nothing in status col #716

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/kernelCI_app/typeModels/databases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from typing import Literal

# "NULL" must be added manually because the database return None
type StatusValues = Literal["FAIL", "PASS", "SKIP", "ERROR", "MISS", "NULL"]
16 changes: 14 additions & 2 deletions backend/kernelCI_app/typeModels/hardwareDetails.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
from pydantic import BaseModel, Field
from typing import Dict, Optional, Union, List
from datetime import datetime
from typing import Annotated, Any, Dict, List, Optional, Union

from kernelCI_app.typeModels.databases import StatusValues
from pydantic import BaseModel, BeforeValidator, Field


def process_status(value: Any) -> Any:
if value is None:
return "NULL"
return value


class DefaultRecordValues(BaseModel):
status: Annotated[StatusValues, BeforeValidator(process_status)]


class PostBody(BaseModel):
Expand Down
9 changes: 7 additions & 2 deletions backend/kernelCI_app/views/hardwareDetailsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
handle_environment_misc,
env_misc_value_or_default
)
from kernelCI_app.typeModels.hardwareDetails import PostBody
from kernelCI_app.typeModels.hardwareDetails import PostBody, DefaultRecordValues
from pydantic import ValidationError

DEFAULT_DAYS_INTERVAL = 3
Expand Down Expand Up @@ -268,7 +268,7 @@ def test_in_filter(self, table_test: Literal["boot", "test"], record: Dict) -> b
return test_filter_pass

def handle_test(self, record, tests):
status = record["status"] or "NULL"
status = record["status"]

tests["history"].append(get_history(record))
tests["statusSummary"][status] += 1
Expand Down Expand Up @@ -343,6 +343,11 @@ def sanitize_records(self, records, trees: List, is_all_selected: bool):
builds = {"items": [], "issues": {}, "failedWithUnknownIssues": 0}

for record in records:
try:
validatedRecord = DefaultRecordValues(**record)
record["status"] = validatedRecord.status
except ValidationError:
continue
current_tree = get_record_tree(record, trees)
if not current_tree:
log_message(f"Tree not found for record: {record}")
Expand Down
Loading