From ee6f3620b8f65846d85e5664dbfe3646ae0829c7 Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Tue, 25 Nov 2025 10:00:32 +0000 Subject: [PATCH] Improve detection filtering by correctly comparing numerical risk scores Fix bug where risk scores were compared lexicographically instead of numerically by casting the `riskScore` column to numeric in SQL queries. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: e12effb9-1a7e-487d-8050-fce814f981ed Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/1zhedLT --- server/storage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/storage.ts b/server/storage.ts index 45b028b..d9fc94b 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -160,8 +160,9 @@ export class DatabaseStorage implements IStorage { conditions.push(eq(detections.anomalyType, anomalyType)); } + // Cast riskScore to numeric for proper comparison (stored as text in DB) if (minScore !== undefined) { - conditions.push(gte(detections.riskScore, minScore.toString())); + conditions.push(sql`${detections.riskScore}::numeric >= ${minScore}`); } if (maxScore !== undefined) {