Skip to main content

Function: pruneHistoryForMonitor()

function pruneHistoryForMonitor(
db: Database,
monitorId: string,
limit: number
): void;

Defined in: electron/services/database/utils/maintenance/historyManipulation.ts:184

Internal

Prune old history entries for a monitor, keeping only the most recent entries.

Parameters​

db​

Database

Database connection instance

monitorId​

string

Unique identifier of the monitor

limit​

number

Maximum number of history entries to retain

Returns​

void

Remarks​

Uses a cheap probe query (LIMIT 1 OFFSET ?) to determine whether pruning is necessary. When pruning is needed, performs a single DELETE statement with a subquery.

This avoids building huge parameter lists that can hit SQLite's variable limit.

Throws​

Error when database operations fail