Shadow-mode client script and cutover doc correction

This commit is contained in:
2026-08-13 11:23:27 -04:00
parent 3abf724ae6
commit 70c5bced37
8 changed files with 455 additions and 25 deletions

View File

@@ -1541,16 +1541,18 @@ def supplies_forecast():
if not supplies:
continue
itemids = [s['itemid'] for s in supplies if s.get('itemid')]
history = service.gethistory(itemids, days=days)
history = service.getlevelhistory(itemids, days=days)
analysed = []
for supply in supplies:
points = history.get(str(supply.get('itemid')), [])
detail = analyse(points)
# The live read is the level the report shows, so it is also the
# level the countdown is computed from - history lags a poll, and a
# row whose level and days-left came from different moments reads
# as broken.
detail = analyse(points, currentlevel=supply.get('level'))
detail['name'] = supply.get('name')
detail['color'] = supply.get('color')
# Trust the live read for the level; history can lag a poll behind.
detail['currentlevel'] = supply.get('level', detail['currentlevel'])
analysed.append(detail)
entry = {