opencode-statboard 2.10.24 → 2.10.26
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/package.json +1 -1
- package/server.js +24 -13
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -871,18 +871,7 @@ function settleBundle(now, msg) {
|
|
|
871
871
|
// Today/7 days/Month/All is an in-memory swap (1–2ms) instead of a build.
|
|
872
872
|
// Each build is ~25ms of pure in-memory work (no DB hit), and they run one
|
|
873
873
|
// per tick so startup never blocks.
|
|
874
|
-
|
|
875
|
-
const scopes = [1, 7, 30, -1];
|
|
876
|
-
const warm = (i) => {
|
|
877
|
-
if (i >= scopes.length) return;
|
|
878
|
-
try {
|
|
879
|
-
const r = buildReportFromDb(scopes[i]);
|
|
880
|
-
if (r && r.stats && r.stats.ok) reportCache[String(scopes[i])] = r;
|
|
881
|
-
} catch (_) {}
|
|
882
|
-
setImmediate(() => warm(i + 1));
|
|
883
|
-
};
|
|
884
|
-
warm(0);
|
|
885
|
-
});
|
|
874
|
+
prewarmReports();
|
|
886
875
|
}
|
|
887
876
|
|
|
888
877
|
// Pure tool-count scan (no cache side effects) so the worker can run it.
|
|
@@ -1368,6 +1357,21 @@ function buildReportFromDb(days) {
|
|
|
1368
1357
|
};
|
|
1369
1358
|
}
|
|
1370
1359
|
|
|
1360
|
+
function prewarmReports() {
|
|
1361
|
+
setImmediate(() => {
|
|
1362
|
+
const scopes = [1, 7, 30, -1];
|
|
1363
|
+
const warm = (i) => {
|
|
1364
|
+
if (i >= scopes.length) return;
|
|
1365
|
+
try {
|
|
1366
|
+
const r = buildReportFromDb(scopes[i]);
|
|
1367
|
+
if (r && r.stats && r.stats.ok) reportCache[String(scopes[i])] = r;
|
|
1368
|
+
} catch (_) {}
|
|
1369
|
+
setImmediate(() => warm(i + 1));
|
|
1370
|
+
};
|
|
1371
|
+
warm(0);
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1371
1375
|
function refreshReport(days) {
|
|
1372
1376
|
const key = String(days);
|
|
1373
1377
|
const hit = reportCache[key];
|
|
@@ -1580,13 +1584,15 @@ async function startServer() {
|
|
|
1580
1584
|
|
|
1581
1585
|
(async () => {
|
|
1582
1586
|
try {
|
|
1583
|
-
await startServer();
|
|
1584
1587
|
// Serve the persisted bundle + tool counts IMMEDIATELY. Nothing on this
|
|
1585
1588
|
// path touches the live DB, so the first request answers in milliseconds
|
|
1586
1589
|
// instead of waiting out a 3-29s scan.
|
|
1587
1590
|
const cached = loadBundleCache();
|
|
1588
1591
|
attrAllCache = cached || null;
|
|
1589
1592
|
getDb(); // detect schema now, so the worker result lands on a warm handle
|
|
1593
|
+
// Reports for every scope are pure in-memory builds off the bundle: do them
|
|
1594
|
+
// now so the first scope click is a swap, not a build.
|
|
1595
|
+
prewarmReports();
|
|
1590
1596
|
// Spawn the fresh scan BEFORE the first refresh: while it is in flight the
|
|
1591
1597
|
// request thread never runs the inline tool scan (toolCountsFor skips it).
|
|
1592
1598
|
refreshAttrBundle();
|
|
@@ -1616,6 +1622,11 @@ async function startServer() {
|
|
|
1616
1622
|
if (t) trendCache[String(d)] = t;
|
|
1617
1623
|
} catch (_) {}
|
|
1618
1624
|
}
|
|
1625
|
+
// Open the port only once there is real data to paint. Listening first made
|
|
1626
|
+
// the browser paint an empty "updating" shell and then swap in numbers,
|
|
1627
|
+
// which is exactly what a 16s LCP looks like. With a cache present this is
|
|
1628
|
+
// ~1s after launch; on a cold machine the wait is the scan itself.
|
|
1629
|
+
await startServer();
|
|
1619
1630
|
setInterval(refresh, REFRESH_MS);
|
|
1620
1631
|
setInterval(refreshModels, 60000);
|
|
1621
1632
|
setInterval(refreshAttrBundle, 60000);
|