Conversation
- FCMClient에 subscribe_to_topic(), send_to_topic() 메서드 추가 - register_fcm에서 DASHBOARD 토큰을 dashboard_alerts 토픽에 자동 구독 - FCM_MOCK 환경변수로 테스트 모드 지원
- ocr_tasks: send_notification 호출을 차량 매칭 조건 밖으로 이동 - notification_tasks: dashboard_alerts 토픽 브로드캐스트 추가 - 차량 개별 푸시와 토픽 브로드캐스트 이중 구조로 개편 - 토픽 알림 이력에 fcm_token="topic:dashboard_alerts" 저장
- 토픽 알림 중복 전송 방지 (autoretry 시 idempotency 체크) - null 안전성 강화 (ocr_result, location 미확인 시 기본값 처리) - Detection.DoesNotExist 시 retry 전략으로 변경 (타이밍 이슈 대응) - apply_async 실패 시 OCR 완료 상태 보호 (try/except 래핑) - 에러 로깅 개선 (silent pass 제거)
- CORS 빈 문자열 폴백 방지 및 중복 설정 제거 (prod.py) - 중복 DB 인덱스 제거 (Detection, Notification, Vehicle) - statistics() 메서드 import 중복 제거 및 period_map 패턴 적용 - 불필요한 __future__ import 제거 (Python 3 전용) - DLQ 태스크 export 누락 보완 (tasks/__init__.py) - QuerySet.update()의 auto_now 우회 관련 주석 추가
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
subscribe_to_topic,send_to_topic)dashboard_alerts토픽에 자동 구독send_notification을 모든 완료된 감지에 대해 호출하도록 변경 (차량 매칭 여부 무관)Background
기존에는
plate_number="DASHBOARD"로 FCM 토큰을 등록했지만, OCR 결과가 "DASHBOARD"와 매칭될 수 없어 대시보드에 알림이 전달되지 않는 구조적 문제가 있었습니다. FCM 토픽 기반으로 전환하여 모든 대시보드 사용자가 실시간 알림을 수신할 수 있도록 합니다.Changes
core/firebase/fcm.py:subscribe_to_topic(),send_to_topic()메서드 및 편의 함수 추가apps/vehicles/views.py:register_fcm에서 DASHBOARD 토큰 → 토픽 자동 구독tasks/ocr_tasks.py:send_notification호출을 차량 매칭 조건 밖으로 이동tasks/notification_tasks.py: 토픽 브로드캐스트 + 차량 개별 푸시 이중 구조Test plan
FCM_MOCK=true환경에서 OCR 완료 후send_notification호출 확인fcm_token="topic:dashboard_alerts"저장 확인