Schedule stale gallery enrichment
This commit is contained in:
@@ -345,9 +345,38 @@ class RuntimeMobileDeSegment:
|
||||
return " / ".join(parts) or self.make_id or "mobilede-segment"
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class RuntimeMobileDeEnrichmentConfig:
|
||||
enabled: bool = True
|
||||
batch_size: int = 10
|
||||
max_existing_images: int = 1
|
||||
staleness_hours: int = 168
|
||||
delay_seconds: float = 1.0
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict[str, Any] | None) -> "RuntimeMobileDeEnrichmentConfig":
|
||||
data = data or {}
|
||||
enabled = _optional_bool(data.get("enabled"))
|
||||
batch_size = _optional_int(data.get("batch_size"))
|
||||
max_existing_images = _optional_int(data.get("max_existing_images"))
|
||||
staleness_hours = _optional_int(data.get("staleness_hours"))
|
||||
try:
|
||||
delay_seconds = float(data.get("delay_seconds", 1.0))
|
||||
except (TypeError, ValueError):
|
||||
delay_seconds = 1.0
|
||||
return cls(
|
||||
enabled=True if enabled is None else enabled,
|
||||
batch_size=max(1, 10 if batch_size is None else batch_size),
|
||||
max_existing_images=max(0, 1 if max_existing_images is None else max_existing_images),
|
||||
staleness_hours=max(0, 168 if staleness_hours is None else staleness_hours),
|
||||
delay_seconds=max(0.0, delay_seconds),
|
||||
)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class RuntimeMobileDeConfig:
|
||||
segments: tuple[RuntimeMobileDeSegment, ...] = ()
|
||||
enrichment: RuntimeMobileDeEnrichmentConfig = field(default_factory=RuntimeMobileDeEnrichmentConfig)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict[str, Any] | None) -> "RuntimeMobileDeConfig":
|
||||
@@ -361,7 +390,10 @@ class RuntimeMobileDeConfig:
|
||||
segment = RuntimeMobileDeSegment.from_dict(item)
|
||||
if segment is not None:
|
||||
segments.append(segment)
|
||||
return cls(segments=tuple(segments))
|
||||
return cls(
|
||||
segments=tuple(segments),
|
||||
enrichment=RuntimeMobileDeEnrichmentConfig.from_dict(data.get("enrichment")),
|
||||
)
|
||||
|
||||
def is_empty(self) -> bool:
|
||||
return not self.segments
|
||||
|
||||
Reference in New Issue
Block a user