@caius_kong/ccusage-dashboard 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server.py +12 -7
- package/package.json +1 -1
package/lib/server.py
CHANGED
|
@@ -101,10 +101,11 @@ TTL = {
|
|
|
101
101
|
_ERROR_TTL = 30
|
|
102
102
|
|
|
103
103
|
# Entries expire this many seconds before their period ends, so the next poll of
|
|
104
|
-
# the same cadence always triggers a fresh scan.
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
# the
|
|
104
|
+
# the same cadence always triggers a fresh scan. Measured from the REQUEST, so it
|
|
105
|
+
# does not care when the scan started. The entry stays valid for
|
|
106
|
+
# `period - _EXPIRY_MARGIN` seconds, which must exceed the total time until a
|
|
107
|
+
# scan's data exists (queueing delay + runtime) or the entry would expire on
|
|
108
|
+
# write — keep the margin small and the period comfortably above one scan.
|
|
108
109
|
_EXPIRY_MARGIN = 5
|
|
109
110
|
|
|
110
111
|
# --- optional self-update check (purely user-triggered) ----------------------
|
|
@@ -703,14 +704,18 @@ def main() -> None:
|
|
|
703
704
|
# back-to-back for no benefit.
|
|
704
705
|
#
|
|
705
706
|
# Only reports the browser asks for on load are pre-warmed: the default
|
|
706
|
-
# view (today), the
|
|
707
|
-
#
|
|
708
|
-
#
|
|
707
|
+
# view (today), the always-visible panels (budget=month, 30-day trend)
|
|
708
|
+
# and the sessions list, which the first tick also requests. Pre-warming
|
|
709
|
+
# sessions matters: otherwise it queues behind the other three cold scans,
|
|
710
|
+
# and a queued run can finish too late to serve the next tick.
|
|
711
|
+
# week/range are omitted on purpose — the UI only fetches them when the
|
|
712
|
+
# user switches to that tab, so warming them would be a wasted
|
|
709
713
|
# full-history scan at every boot.
|
|
710
714
|
jobs = [
|
|
711
715
|
lambda: run_ccusage(["daily", "--last", "1", "--json", "--offline"], TTL["/api/today"]),
|
|
712
716
|
lambda: run_ccusage(["monthly", "--last", "1", "--json", "--offline"], TTL["/api/month"]),
|
|
713
717
|
lambda: trend(30),
|
|
718
|
+
lambda: sessions(period="today"),
|
|
714
719
|
]
|
|
715
720
|
threads = [threading.Thread(target=job) for job in jobs]
|
|
716
721
|
for t in threads:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caius_kong/ccusage-dashboard",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
4
4
|
"description": "One-command local dashboard for ccusage: today/week/month/custom cost by model, 30-day trend, monthly budget alert. Numbers straight from ccusage.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|