Open matthiasschaub opened 1 year ago
Could look like
class Result(BaseModel):
"""The result of the Indicator.
Attributes:
timestamp (datetime): Timestamp of the creation of the indicator
timestamp_osm (datetime): Timestamp of the used OSM data
(e.g. Latest timestamp of the ohsome API results)
label (str): Traffic lights like quality label: `green`, `yellow` or `red`. The
value is determined by the result classes
value (float): The result value
class_ (int): The result class. An integer between 1 and 5. It maps to the
result labels. This value is used by the reports to determine an overall
result.
description (str): The result description.
"""
description: str
timestamp: datetime = Field(default=datetime.now(timezone.utc))
timestamp_osm: datetime | None = Field(default=None, alias="timestampOSM")
value: float | None = None
class_: Literal[1, 2, 3, 4, 5] | None = None
figure: dict | None = None
labels: dict = {1: "red", 2: "yellow", 3: "yellow", 4: "green", 5: "green"}
model_config = ConfigDict(
alias_generator=snake_to_lower_camel,
extra="forbid",
populate_by_name=True,
)
@computed_field
@property
def label(self) -> Literal["green", "yellow", "red", "undefined"]:
return self.labels.get(self.class_, "undefined")
Currently, labels are either red, yellow or green.
Suggestion: Labels should describe quality dimension. E.g. for quality dimension "completeness" label should be either low, medium or high.