fix: refresh vehicle asset statistics every 5 seconds
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -167,7 +167,7 @@ export default function AssetsModule() {
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
const interval = setInterval(loadData, 60 * 1000);
|
||||
const interval = setInterval(loadData, 5 * 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, [loadData]);
|
||||
|
||||
|
||||
@@ -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')]);
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
Reference in New Issue
Block a user