Skip to content

Commit

Permalink
fix: show 'NULL' instead of nothing in status col
Browse files Browse the repository at this point in the history
Closes #714
  • Loading branch information
murilx committed Dec 24, 2024
1 parent 7141c73 commit 6e2f30d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
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

0 comments on commit 6e2f30d

Please sign in to comment.