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
This commit is contained in:
marco370 2025-11-25 10:00:32 +00:00
parent 83e2d1b1bb
commit ee6f3620b8

View File

@ -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) {