mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 06:35:24 +00:00
fix: high cpu from status probes and full database saves on every sample (#1300)
This commit is contained in:
1 parent
11a22d30eb
commit
79bd10a1b0
10 files changed
+241
-22
No files matched your search
@@ -304,7 +304,7 @@ export async function createAlertsRepository(
|
||||
dedupeKey: item.dedupeKey ?? null,
|
||||
createdAt,
|
||||
});
|
||||
await db.persist();
|
||||
await db.persist({ lazy: true });
|
||||
return toItem({
|
||||
id,
|
||||
...item,
|
||||
@@ -322,7 +322,7 @@ export async function createAlertsRepository(
|
||||
.update(items)
|
||||
.set({ deliveries: JSON.stringify(results) })
|
||||
.where(eq(items.id, id));
|
||||
await db.persist();
|
||||
await db.persist({ lazy: true });
|
||||
},
|
||||
|
||||
async hasUnreadWithKey(userId: string, key: string): Promise<boolean> {
|
||||
|
||||
@@ -528,7 +528,7 @@ export async function createAutomationRepository(
|
||||
.set({ lastRunAt: run[0].startedAt, lastRunStatus: input.status })
|
||||
.where(eq(automations.id, run[0].automationId));
|
||||
}
|
||||
await db.persist();
|
||||
await db.persist({ lazy: true });
|
||||
},
|
||||
|
||||
async listRuns(
|
||||
@@ -630,7 +630,7 @@ export async function createAutomationRepository(
|
||||
.where(lt(runs.startedAt, cutoff));
|
||||
if (old.length === 0) return 0;
|
||||
await drizzle.delete(runs).where(lt(runs.startedAt, cutoff));
|
||||
await db.persist();
|
||||
await db.persist({ lazy: true });
|
||||
return old.length;
|
||||
},
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ export async function createHostMetricsRepository(db: PluginDatabase) {
|
||||
)
|
||||
: scope,
|
||||
);
|
||||
await db.persist();
|
||||
await db.persist({ lazy: true });
|
||||
},
|
||||
|
||||
async listHealth(
|
||||
|
||||
@@ -40,7 +40,7 @@ export function createProxmoxNodeHistoryRepository(
|
||||
async create(input: ProxmoxNodeHistoryCreateInput): Promise<void> {
|
||||
const drizzle = await client();
|
||||
await drizzle.insert(table).values(input);
|
||||
await db.persist();
|
||||
await db.persist({ lazy: true });
|
||||
},
|
||||
|
||||
async listRange(
|
||||
@@ -73,7 +73,7 @@ export function createProxmoxNodeHistoryRepository(
|
||||
await drizzle
|
||||
.delete(table)
|
||||
.where(and(eq(table.hostId, hostId), lt(table.ts, cutoff)));
|
||||
await db.persist();
|
||||
await db.persist({ lazy: true });
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user