Stelle den Frontend-MVP und die v0.3-API auf develop bereit, damit Dev API und PWA zusammen deployen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
827e6a2a11
commit
b276758ee1
152 files changed
+25846
-34
No files matched your search
@@ -0,0 +1,45 @@
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from typing import Iterable
|
||||
|
||||
from app.domain.enums import NormalizationStatus
|
||||
from app.domain.models import AttributeStatement
|
||||
|
||||
|
||||
def statement_is_usable(statement: AttributeStatement | None, minimum_confidence: Decimal) -> bool:
|
||||
if statement is None:
|
||||
return False
|
||||
if statement.normalization_status != NormalizationStatus.NORMALIZED:
|
||||
return False
|
||||
if statement.normalized_value is None:
|
||||
return False
|
||||
return statement.confidence >= minimum_confidence
|
||||
|
||||
|
||||
def select_attribute_snapshot(
|
||||
statements: Iterable[AttributeStatement],
|
||||
*,
|
||||
as_of: datetime,
|
||||
snapshot_cutoff: datetime,
|
||||
) -> dict[str, AttributeStatement]:
|
||||
"""Pick the newest statement per key at or before the evaluation cutoff."""
|
||||
chosen: dict[str, AttributeStatement] = {}
|
||||
for statement in statements:
|
||||
if statement.observed_at > as_of or statement.ingested_at > snapshot_cutoff:
|
||||
continue
|
||||
current = chosen.get(statement.attribute)
|
||||
if current is None or _is_newer(statement, current):
|
||||
chosen[statement.attribute] = statement
|
||||
return chosen
|
||||
|
||||
|
||||
def _is_newer(candidate: AttributeStatement, current: AttributeStatement) -> bool:
|
||||
return (
|
||||
candidate.observed_at,
|
||||
candidate.ingested_at,
|
||||
candidate.id,
|
||||
) > (
|
||||
current.observed_at,
|
||||
current.ingested_at,
|
||||
current.id,
|
||||
)
|
||||
Reference in new issue
Block a user