diff --git a/listener/src/api/events-server.ts b/listener/src/api/events-server.ts index 3140500..197e189 100644 --- a/listener/src/api/events-server.ts +++ b/listener/src/api/events-server.ts @@ -461,8 +461,6 @@ export function createEventsServer(options: EventsServerOptions): http.Server { logger.info('GET /api/notifications/history complete', { requestId, - correlationId, - returned: result.records.length, total: result.total, durationMs: Date.now() - startTime, }); @@ -486,10 +484,7 @@ export function createEventsServer(options: EventsServerOptions): http.Server { const userId = decodeURIComponent(getPrefsMatch[1]); logger.info('Handling GET /api/preferences/:userId', { requestId, correlationId, userId }); const prefs = preferenceStore.get(userId); - logger.info('GET /api/preferences/:userId complete', { requestId, correlationId, userId, durationMs: Date.now() - startTime }); - res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(prefs)); - return; } // PUT /api/preferences/:userId @@ -520,7 +515,6 @@ export function createEventsServer(options: EventsServerOptions): http.Server { }); return; } - logger.warn('Unhandled request', { requestId, correlationId, method: req.method, url: req.url }); res.writeHead(404, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ error: 'Not found' })); diff --git a/listener/src/database/schema.sql b/listener/src/database/schema.sql index b303b4a..4591ca0 100644 --- a/listener/src/database/schema.sql +++ b/listener/src/database/schema.sql @@ -38,6 +38,9 @@ CREATE TABLE IF NOT EXISTS scheduled_notifications ( ); -- Indexes for performance optimization +CREATE INDEX IF NOT EXISTS idx_scheduled_notifications_status + ON scheduled_notifications(status); + CREATE INDEX IF NOT EXISTS idx_scheduled_notifications_status_execute_at ON scheduled_notifications(status, execute_at) WHERE status = 'PENDING'; @@ -76,6 +79,9 @@ CREATE INDEX IF NOT EXISTS idx_execution_log_notification_id CREATE INDEX IF NOT EXISTS idx_execution_log_execution_time ON notification_execution_log(execution_time); +CREATE INDEX IF NOT EXISTS idx_execution_log_status_execution_time + ON notification_execution_log(status, execution_time); + -- Trigger to update updated_at timestamp CREATE TRIGGER IF NOT EXISTS update_scheduled_notifications_timestamp AFTER UPDATE ON scheduled_notifications