fix: include the oldest dashboard window boundary

This commit is contained in:
Eneko Ruiz committed 2026-10-17 14:15:12 +02:00
1 parent 76aaa77df6
commit e32d1a4e4d
2 files changed
+20 -1

No files matched your search

+1 -1
View File
@@ -69,7 +69,7 @@ function bucketByDay(records, nowMs, days) {
}
for (const bucket of buckets) {
if (recordMs > bucket.start && recordMs <= bucket.end) {
if (recordMs >= bucket.start && recordMs <= bucket.end) {
bucket.records.push(record);
break;
}
+19
View File
@@ -11,6 +11,7 @@ const path = require('path');
const { spawnSync } = require('child_process');
const dashboard = require('../../scripts/lib/skill-evolution/dashboard');
const health = require('../../scripts/lib/skill-evolution/health');
const versioning = require('../../scripts/lib/skill-evolution/versioning');
const _provenance = require('../../scripts/lib/skill-evolution/provenance');
@@ -148,6 +149,24 @@ function runTests() {
}
})) passed++; else failed++;
if (test('bucketByDay includes the window cutoff without duplicating internal boundaries', () => {
const nowMs = Date.parse(now);
const records = [
{ outcome: 'failure', recorded_at: '2026-03-12T12:00:00.000Z' },
{ outcome: 'success', recorded_at: '2026-03-13T12:00:00.000Z' },
{ outcome: 'success', recorded_at: '2026-03-14T12:00:00.000Z' },
{ outcome: 'success', recorded_at: now },
{ outcome: 'failure', recorded_at: '2026-03-12T11:59:59.999Z' },
{ outcome: 'failure', recorded_at: '2026-03-15T12:00:00.001Z' },
];
const buckets = dashboard.bucketByDay(records, nowMs, 3);
const windowRecords = health.filterRecordsWithinDays(records, nowMs, 3);
assert.strictEqual(windowRecords.length, 4);
assert.deepStrictEqual(buckets.map(bucket => bucket.runs), [2, 1, 1]);
assert.strictEqual(buckets.reduce((total, bucket) => total + bucket.runs, 0), windowRecords.length);
assert.strictEqual(buckets[0].rate, 0.5);
})) passed++; else failed++;
console.log('\nPanel renderers:');
const alphaSkillDir = createSkill(skillsRoot, 'alpha', '# Alpha\n');