fix: refresh vehicle asset statistics every 5 seconds
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
shishengliang
2026-09-22 19:50:58 +08:00
parent 96b64a7872
commit 9b0980e349
3 changed files with 4 additions and 4 deletions
@@ -49,7 +49,7 @@ test('keeps all vehicle GET endpoints in their established order', () => {
assert.doesNotMatch(source, /\bSELECT\b|pool\.query|MAIN_SQL/);
});
test('keeps the non-empty vehicle cache for less than 60 seconds', async () => {
test('keeps the non-empty vehicle cache for less than 5 seconds', async () => {
let now = 100_000;
const db = new FakeDatabase([[{ id: 'first' }], [{ id: 'second' }]]);
const repository = new VehicleRepository(
@@ -59,7 +59,7 @@ test('keeps the non-empty vehicle cache for less than 60 seconds', async () => {
);
assert.deepEqual(await repository.getVehicles(), [vehicle('first')]);
now += 59_999;
now += 4_999;
assert.deepEqual(await repository.getVehicles(), [vehicle('first')]);
now += 1;
assert.deepEqual(await repository.getVehicles(), [vehicle('second')]);
+1 -1
View File
@@ -278,7 +278,7 @@ export const FLOW_STATS_SQL = `
ORDER BY flow.event_time DESC, flow.id DESC
`;
const CACHE_TTL = 60 * 1000;
const CACHE_TTL = 5 * 1000;
export class VehicleRepository {
private cachedVehicles: Vehicle[] = [];