Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api: ✨ 미확인 푸시 알림 존재 여부 확인 API #139

Merged
merged 11 commits into from
Jul 25, 2024

Conversation

psychology50
Copy link
Member

@psychology50 psychology50 commented Jul 25, 2024

작업 이유

  • 사용자가 확인하지 않은 푸시 알림이 존재하는지 확인하기 위한 API

작업 사항

  • url: GET /v2/notifications/unread

unread 라는 이름이 마음에 안 드네요.. not-confirmation이 맥락 상 적절하긴 한데 너무 길어서 일단 unread로 처리.

처음에 jpa repository로 쿼리를 생성했고, 메서드 명은 existsByReceiver_IdAndReadAtIsNull이었습니다.
Jpa method rule에 의해, join 없이 receiver_id FK를 탐색할 것이라 생각했으나, 예상이랑 다른 쿼리가 나가는 것을 확인했습니다.

image

필드명도 수정해보았으나 진척이 없어, QueryDsl로 명시적으로 수정하였고 다음과 같은 결과를 얻었습니다.

image

image

-> Limit: 1 row(s)  (cost=0.59 rows=1) (actual time=0.053..0.053 rows=0 loops=1)
    -> Filter: (notification.read_at is null)  (cost=0.59 rows=1) (actual time=0.052..0.052 rows=0 loops=1)
        -> Index lookup on notification using receiver (receiver=10)  (cost=0.59 rows=6) (actual time=0.047..0.049 rows=6 loops=1)

join도 없고, ref 타입으로 값을 잘 조회하고 있으므로 빠른 성능을 기대할 수 있습니다.
또한 Limit 절에 의해 값을 찾는 즉시 실행이 종료되므로, 대용량 데이터를 가지고 있어도 큰 지장이 없을 거라 생각합니다.


리뷰어가 중점적으로 확인해야 하는 부분

  • unread 말고 더 좋은 네이밍이 있을지

발견한 이슈

  • 없음.

@psychology50 psychology50 added the enhancement New feature or request label Jul 25, 2024
@psychology50 psychology50 self-assigned this Jul 25, 2024
@psychology50 psychology50 merged commit ab0de1e into dev Jul 25, 2024
1 check passed
@psychology50 psychology50 deleted the feat/PW-439-check-unconfirmed-push-notify branch July 25, 2024 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant