fix: vessel_store _last_bucket 타임존 오류 수정
snpdb time_bucket은 tz-naive KST인데 UTC tzinfo를 강제 부여하여 incremental fetch WHERE time_bucket > %s 비교 시 미래 시간으로 해석, 항상 0 rows 반환 → 1h 어구 그룹이 점진적으로 소멸하는 버그. tz-naive 그대로 유지하도록 수정 (load_initial, merge_incremental 3곳). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
부모
e9ae058017
커밋
d15039ce18
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
### 수정
|
### 수정
|
||||||
- 1h 활성 판정을 parent_name 전체 합산 기준으로 변경 (서브클러스터 분리 후 개별 소수 문제 해결)
|
- 1h 활성 판정을 parent_name 전체 합산 기준으로 변경 (서브클러스터 분리 후 개별 소수 문제 해결)
|
||||||
|
- vessel_store의 _last_bucket 타임존 오류 수정 (tz-naive KST → UTC 잘못 변환 → incremental fetch 0건)
|
||||||
|
|
||||||
## [2026-04-01.2]
|
## [2026-04-01.2]
|
||||||
|
|
||||||
|
|||||||
13
prediction/cache/vessel_store.py
vendored
13
prediction/cache/vessel_store.py
vendored
@ -114,19 +114,20 @@ class VesselStore:
|
|||||||
self._tracks[str(mmsi)] = group.reset_index(drop=True)
|
self._tracks[str(mmsi)] = group.reset_index(drop=True)
|
||||||
|
|
||||||
# last_bucket 설정 — incremental fetch 시작점
|
# last_bucket 설정 — incremental fetch 시작점
|
||||||
|
# snpdb time_bucket은 tz-naive KST이므로 UTC 변환하지 않고 그대로 유지
|
||||||
if 'time_bucket' in df_all.columns and not df_all['time_bucket'].dropna().empty:
|
if 'time_bucket' in df_all.columns and not df_all['time_bucket'].dropna().empty:
|
||||||
max_bucket = pd.to_datetime(df_all['time_bucket'].dropna()).max()
|
max_bucket = pd.to_datetime(df_all['time_bucket'].dropna()).max()
|
||||||
if hasattr(max_bucket, 'to_pydatetime'):
|
if hasattr(max_bucket, 'to_pydatetime'):
|
||||||
max_bucket = max_bucket.to_pydatetime()
|
max_bucket = max_bucket.to_pydatetime()
|
||||||
if isinstance(max_bucket, datetime) and max_bucket.tzinfo is None:
|
if isinstance(max_bucket, datetime) and max_bucket.tzinfo is not None:
|
||||||
max_bucket = max_bucket.replace(tzinfo=timezone.utc)
|
max_bucket = max_bucket.replace(tzinfo=None)
|
||||||
self._last_bucket = max_bucket
|
self._last_bucket = max_bucket
|
||||||
elif 'timestamp' in df_all.columns and not df_all['timestamp'].dropna().empty:
|
elif 'timestamp' in df_all.columns and not df_all['timestamp'].dropna().empty:
|
||||||
max_ts = pd.to_datetime(df_all['timestamp'].dropna()).max()
|
max_ts = pd.to_datetime(df_all['timestamp'].dropna()).max()
|
||||||
if hasattr(max_ts, 'to_pydatetime'):
|
if hasattr(max_ts, 'to_pydatetime'):
|
||||||
max_ts = max_ts.to_pydatetime()
|
max_ts = max_ts.to_pydatetime()
|
||||||
if isinstance(max_ts, datetime) and max_ts.tzinfo is None:
|
if isinstance(max_ts, datetime) and max_ts.tzinfo is not None:
|
||||||
max_ts = max_ts.replace(tzinfo=timezone.utc)
|
max_ts = max_ts.replace(tzinfo=None)
|
||||||
self._last_bucket = max_ts
|
self._last_bucket = max_ts
|
||||||
|
|
||||||
vessel_count = len(self._tracks)
|
vessel_count = len(self._tracks)
|
||||||
@ -171,8 +172,8 @@ class VesselStore:
|
|||||||
|
|
||||||
if new_buckets:
|
if new_buckets:
|
||||||
latest = max(new_buckets)
|
latest = max(new_buckets)
|
||||||
if isinstance(latest, datetime) and latest.tzinfo is None:
|
if isinstance(latest, datetime) and latest.tzinfo is not None:
|
||||||
latest = latest.replace(tzinfo=timezone.utc)
|
latest = latest.replace(tzinfo=None)
|
||||||
if self._last_bucket is None or latest > self._last_bucket:
|
if self._last_bucket is None or latest > self._last_bucket:
|
||||||
self._last_bucket = latest
|
self._last_bucket = latest
|
||||||
|
|
||||||
|
|||||||
불러오는 중...
Reference in New Issue
Block a user