Skip to main content

Function: getLatestHistoryEntry()

function getLatestHistoryEntry(
db: Database,
monitorId: string
): StatusHistory | undefined;

Defined in: electron/services/database/utils/queries/historyQuery.ts:174

Internal

Get the most recent history entry for a monitor.

Parameters​

db​

Database

Database connection instance

monitorId​

string

Unique identifier of the monitor

Returns​

| StatusHistory | undefined

Most recent StatusHistory object, or undefined if no entries exist

Remarks​

Repository Context: Called from HistoryRepository.getLatestEntry() which handles async operations and error recovery via withDatabaseOperation().

Query Behavior: Uses ORDER BY timestamp DESC LIMIT 1 to get the most recent entry. Returns undefined for monitors with no history entries.

Throws​

Error when database query fails