Repository navigation
Plan history: show the latest finished slot, and stop the false 'stale' warning - #5414
Open
chalfontchubby wants to merge 1 commit into
Open
chalfontchubby wants to merge 1 commit into
chalfontchubby wants to merge 1 commit into
Conversation
…ss by each view's own refresh interval The plan page's History view is built by calculate_yesterday() from what actually happened, at most once every 59 minutes. The live Plan view starts at the current slot, so the slots finished since the last rebuild showed in neither view: at 21:35 the History stopped at 20:30 and the Plan started at 21:30. And the page judged every view against the live plan's 15-minute stale limit, so on the History view it warned "Plan data is stale" for about 45 minutes of every hour although nothing was wrong. - calculate_yesterday() now rebuilds once per completed plan slot (plan_interval_minutes), on the first re-plan at least one run (5 minutes) after the slot ends, so the boundary run's own cost_today write is recorded before its history is read back. A rebuild takes 0.4-0.9 s on a live install; at the default 30-minute slots that is 48 a day instead of 24 (before #2913 it ran on every re-plan, about 144). - Each dataset the page shows carries refresh_minutes, the longest Predbat should take to republish it (the live plan: calculate_plan_every; the plan history: a slot, the run it waits and a re-plan interval). The page warns a run after that, never under 15 minutes, against the data the current view shows, and hides the warning when the view has no data. At the defaults: Plan 15 minutes (as before), History 50. Trade-offs, kept: with calculate_plan_every at or above the slot length, re-plans can fall on slot boundaries and the rebuild then happens there; cost_yesterday and savings_yesterday_* roll over at the first re-plan after 00:05 rather than at 00:00; cost_yesterday/savings_yesterday_predbat, with their large html/json attributes, are written twice as often. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Posted by Claude on behalf of @chalfontchubby.
Summary
The web page's Plan → History view had two problems:
With this change History is rebuilt once per completed slot, so the last finished slot shows within one or two re-plans of ending. Each view is judged against how often it is actually republished, so the warning only appears when something has really stopped.
Detail
Rebuild cadence:
calculate_yesterday()plan_interval_minutes), on the first re-plan at least one run (5 minutes) after the slot ends. The wait is so that the boundary run's ownpredbat.cost_todaywrite is already recorded when its history is read back. The key ishistory_slot(), a (date, slot number) shifted byPREDICT_STEP.Stale warning:
get_plan_renderer_js()refresh_minutes, the longest Predbat should take to republish it:calculate_plan_every, set only when the plan is publishedcurrentViewData()), and the "no data yet" text no longer says "about once an hour".Trade-offs, accepted
calculate_plan_everyat or above the slot length, re-plans can fall on slot boundaries, and the rebuild then happens on the boundary run.cost_yesterdayandsavings_yesterday_*roll over at the first re-plan after 00:05, rather than at 00:00. The 1 am savings-total update still sees the new day.cost_yesterdayandsavings_yesterday_predbat, which have large html/json attributes, are written twice as often.Tests
test_calculate_yesterday:refresh_minuteson the published History and baseline data"{}"(a string) wherepublish_html_planandplan_write_debugreturn a dict. They now match the real functions.test_plan_staleness_js: structural checks on the page script (the per-view data, the limit arithmetic, hiding the warning without data, no remaining bare-timestamp checks). It fails on main's script../run_all --quickpass. The rendered page script passesnode --check.🤖 Generated with Claude Code