update all page to refresh immidiately without clicking sync button or refreshing the whole page

This commit is contained in:
Alberto-Audrix committed 2026-10-07 11:17:44 +07:00
1 parent d5b0c12c40
commit 83a41fbbcb
15 files changed
+490 -151

No files matched your search

@@ -255,6 +255,11 @@ def sync_chicken_counting_for_cycle(
obj.save(update_fields=update_fields)
upserted.append(day)
if upserted:
from apps.operations.services.kpi_rollups import refresh_kpi_source_fields
refresh_kpi_source_fields(cycle)
return {"dates": upserted, "upserted": len(upserted), "skipped": False}
@@ -329,4 +334,9 @@ def sync_chicken_weight_for_cycle(
upserted.append(day)
prev_weight = average_weight
if upserted:
from apps.operations.services.kpi_rollups import refresh_kpi_source_fields
refresh_kpi_source_fields(cycle)
return {"dates": upserted, "upserted": len(upserted), "skipped": False}
@@ -326,6 +326,9 @@ def sync_karung_for_cycle(
feed_sack, summary = request_karung(cycle, section=section)
history_dates = backfill_karung_from_combined(cycle)
recompute_feed_sack_totals(cycle)
from apps.operations.services.kpi_rollups import refresh_kpi_source_fields
refresh_kpi_source_fields(cycle)
feed_sack.refresh_from_db()
summary = {
**summary,
@@ -70,6 +70,7 @@ def refresh_kpi_source_fields(cycle: Cycle, *, through: date | None = None) -> i
cc = countings.get(day)
cw = weights.get(day)
fs = feeds.get(day)
if not all([manual, cc, cw, fs]):
# Still accumulate harvest age sum from manual-only days so later
# complete days keep a correct running Σ(age×harvest).