Function: pruneHistoryForMonitor()
pruneHistoryForMonitor(
db
:Database
,monitorId
:string
,limit
:number
):void
Defined in: electron/services/database/utils/historyManipulation.ts:259
Internal
Prune old history entries for a monitor, keeping only the most recent entries.
Parameters
db
Database connection instance
monitorId
string
Unique identifier of the monitor
limit
number
Maximum number of history entries to retain
Returns
void
Remarks
Algorithm: Uses LIMIT -1 OFFSET ?
to select all entries beyond the most
recent limit
entries. In SQLite, LIMIT -1
means "no limit", and combined
with OFFSET
, this efficiently identifies excess entries for deletion.
Transaction Context: Designed to be called from repository methods within transaction context. Used by HistoryRepository.pruneHistoryInternal() and HistoryRepository.pruneAllHistoryInternal().
Performance: Only executes DELETE when excess entries exist to avoid unnecessary operations.
Throws
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error When database operations fail