Skip to main content

Function: pruneHistoryForMonitor()

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

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

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

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When database operations fail