Persist material consumption snapshots

This commit is contained in:
admin committed 2026-09-05 11:35:25 +02:00
1 parent 7c029759f5
commit ae13c3c35a
9 files changed
+303 -17

No files matched your search

@@ -20,6 +20,10 @@ from production_analytics.service.material_polling import (
)
from production_analytics.service.material_runner import MaterialPollingRunner, MaterialStateError
from production_analytics.service.material_state_store import JsonMaterialStateStore
from production_analytics.service.postgres_material import (
PostgresMaterialSnapshotWriter,
PostgresSettings,
)
class _ReportingStateStore:
@@ -64,6 +68,7 @@ def build_material_runner(
raise ConfigurationError(
f"State directory startup check failed: {type(exc).__name__}"
) from exc
postgres_settings = PostgresSettings.from_environment(environment)
service = MaterialPollingService(
gateway=EnlyzeApiGateway(ExplorationClient(settings)),
state_store=_ReportingStateStore(JsonMaterialStateStore(state_directory)),
@@ -74,5 +79,7 @@ def build_material_runner(
max_sample_gap_seconds=calculation.max_sample_gap_seconds,
)
return MaterialPollingRunner(
service, machine_id=calculation.machine_ref, poll_interval_seconds=poll_interval_seconds,
service, calculation_id=calculation.id,
snapshot_writer=PostgresMaterialSnapshotWriter(postgres_settings),
machine_id=calculation.machine_ref, poll_interval_seconds=poll_interval_seconds,
)