From ec5ace986d307cadf9942682e36eb84ec280b395 Mon Sep 17 00:00:00 2001 From: TheFlow Date: Fri, 24 Oct 2025 10:22:41 +1300 Subject: [PATCH] fix(analytics): remove duplicate sessionId index in PageViewSchema - PageViewSchema had 'index: true' on sessionId field (line 16) - AND compound index PageViewSchema.index({ sessionId: 1, timestamp: -1 }) - Compound index already covers sessionId queries (leftmost prefix) - Removed redundant single-field index to eliminate Mongoose warning --- .claude/session-state.json | 16 ++++++++-------- src/models/Analytics.model.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.claude/session-state.json b/.claude/session-state.json index b2992944..29e6f43f 100644 --- a/.claude/session-state.json +++ b/.claude/session-state.json @@ -43,7 +43,7 @@ "last_deliberation": null }, "FileEditHook": { - "timestamp": "2025-10-23T21:21:14.842Z", + "timestamp": "2025-10-23T21:22:32.195Z", "file": "/home/theflow/projects/tractatus/src/models/Analytics.model.js", "result": "passed" }, @@ -58,25 +58,25 @@ "tokens": 30000 }, "alerts": [], - "last_updated": "2025-10-23T21:21:14.842Z", + "last_updated": "2025-10-23T21:22:32.196Z", "initialized": true, "framework_components": { "CrossReferenceValidator": { "message": 0, "tokens": 0, - "timestamp": "2025-10-23T21:21:26.151Z", - "last_validation": "2025-10-23T21:21:26.150Z", - "validations_performed": 679 + "timestamp": "2025-10-23T21:22:38.898Z", + "last_validation": "2025-10-23T21:22:38.898Z", + "validations_performed": 683 }, "BashCommandValidator": { "message": 0, "tokens": 0, "timestamp": null, - "last_validation": "2025-10-23T21:21:26.152Z", - "validations_performed": 337, + "last_validation": "2025-10-23T21:22:38.899Z", + "validations_performed": 340, "blocks_issued": 37 } }, - "action_count": 337, + "action_count": 340, "auto_compact_events": [] } \ No newline at end of file diff --git a/src/models/Analytics.model.js b/src/models/Analytics.model.js index 51c8519c..e420c02d 100644 --- a/src/models/Analytics.model.js +++ b/src/models/Analytics.model.js @@ -13,7 +13,7 @@ const PageViewSchema = new mongoose.Schema({ // Visitor Information (privacy-respecting) visitorId: { type: String, required: true, index: true }, // Hashed IP + User Agent - sessionId: { type: String, required: true, index: true }, // Session identifier + sessionId: { type: String, required: true }, // Session identifier (indexed via compound index below) // Request Details userAgent: { type: String },