fix: correlations API SQL — raw_metrics LATERAL JOIN으로 세부 메트릭 조회
scores 테이블에는 composite 점수만, 세부 메트릭(proximity/visit/heading)은 raw_metrics에 있으므로 LATERAL JOIN으로 최신 raw 메트릭 결합 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
부모
d025809793
커밋
82fb6fbfff
@ -61,11 +61,17 @@ public class GroupPolygonService {
|
||||
private static final String GROUP_CORRELATIONS_SQL = """
|
||||
SELECT s.target_mmsi, s.target_type, s.target_name,
|
||||
s.current_score, s.streak_count, s.observation_count,
|
||||
s.freeze_state,
|
||||
s.proximity_ratio, s.visit_score, s.heading_coherence,
|
||||
s.freeze_state, s.shadow_bonus_total,
|
||||
r.proximity_ratio, r.visit_score, r.heading_coherence,
|
||||
m.id AS model_id, m.name AS model_name, m.is_default
|
||||
FROM kcg.gear_correlation_scores s
|
||||
JOIN kcg.correlation_param_models m ON s.model_id = m.id
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT proximity_ratio, visit_score, heading_coherence
|
||||
FROM kcg.gear_correlation_raw_metrics
|
||||
WHERE group_key = s.group_key AND target_mmsi = s.target_mmsi
|
||||
ORDER BY observed_at DESC LIMIT 1
|
||||
) r ON TRUE
|
||||
WHERE s.group_key = ? AND s.current_score >= ? AND m.is_active = TRUE
|
||||
ORDER BY m.is_default DESC, s.current_score DESC
|
||||
""";
|
||||
@ -107,6 +113,7 @@ public class GroupPolygonService {
|
||||
row.put("streak", rs.getInt("streak_count"));
|
||||
row.put("observations", rs.getInt("observation_count"));
|
||||
row.put("freezeState", rs.getString("freeze_state"));
|
||||
row.put("shadowBonus", rs.getDouble("shadow_bonus_total"));
|
||||
row.put("proximityRatio", rs.getObject("proximity_ratio"));
|
||||
row.put("visitScore", rs.getObject("visit_score"));
|
||||
row.put("headingCoherence", rs.getObject("heading_coherence"));
|
||||
|
||||
불러오는 중...
Reference in New Issue
Block a user