fix: 라이브 어구 현황 fallback 제외 + FLEET resolution #216

병합
htlee bugfix/fleet-resolution-fix 에서 develop 로 3 commits 를 머지했습니다 2026-04-01 15:03:12 +09:00
3개의 변경된 파일13개의 추가작업 그리고 6개의 파일을 삭제

파일 보기

@ -2,7 +2,7 @@
-- 기존 데이터는 DEFAULT '6h'로 취급
ALTER TABLE kcg.group_polygon_snapshots
ADD COLUMN IF NOT EXISTS resolution VARCHAR(4) DEFAULT '6h';
ADD COLUMN IF NOT EXISTS resolution VARCHAR(8) DEFAULT '6h';
-- 기존 인덱스 교체: resolution 포함
DROP INDEX IF EXISTS kcg.idx_gps_type_time;

파일 보기

@ -180,7 +180,7 @@ export function FleetClusterLayer({ ships, analysisMap: analysisMapProp, onShipS
]);
// 2. resolution별 분리 → 1h(primary) + 6h(secondary)
const history1h = history.filter(h => h.resolution === '1h');
const history1h = history.filter(h => h.resolution === '1h' || h.resolution === '1h-fb');
const history6h = history.filter(h => h.resolution === '6h');
// fallback: resolution 필드 없는 기존 데이터는 6h로 취급
const effective1h = history1h.length > 0 ? history1h : history;

파일 보기

@ -399,6 +399,7 @@ def build_all_group_snapshots(
'group_type': 'FLEET',
'group_key': str(company_id),
'group_label': group_label,
'resolution': '1h',
'snapshot_time': now,
'polygon_wkt': polygon_wkt,
'center_wkt': center_wkt,
@ -422,12 +423,16 @@ def build_all_group_snapshots(
continue
# ── 1h 활성 멤버 필터 ──
display_members_1h = [
active_members_1h = [
gm for gm in gear_members
if _get_time_bucket_age(gm.get('mmsi'), all_positions, now) <= DISPLAY_STALE_SEC
]
# fallback: 1h < 2이면 time_bucket 최신 2개 유지 (폴리곤 형태 보존)
if len(display_members_1h) < 2 and len(gear_members) >= 2:
active_count_1h = len(active_members_1h)
# fallback: 1h < 2이면 time_bucket 최신 2개 유지 (리플레이/일치율 추적용)
# 라이브 현황에서는 active_count_1h로 필터 (fallback 그룹 제외)
display_members_1h = active_members_1h
if active_count_1h < 2 and len(gear_members) >= 2:
sorted_by_age = sorted(
gear_members,
key=lambda gm: _get_time_bucket_age(gm.get('mmsi'), all_positions, now),
@ -442,7 +447,9 @@ def build_all_group_snapshots(
display_members_6h = gear_members
# ── resolution별 스냅샷 생성 ──
for resolution, members_for_snap in [('1h', display_members_1h), ('6h', display_members_6h)]:
# 1h-fb: fallback (실제 1h 활성 < 2) — 리플레이/일치율 추적용, 라이브 현황에서 제외
res_1h = '1h' if active_count_1h >= 2 else '1h-fb'
for resolution, members_for_snap in [(res_1h, display_members_1h), ('6h', display_members_6h)]:
if len(members_for_snap) < 2:
continue
# 6h: 최신 적재가 STALE_SEC(6h) 초과 시 스킵