-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Create notification FastAPI #468
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
일단 코드가 돌아가는지 확인해 주세요
related_comment_id=notification.related_comment_id, | ||
is_read=False | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_read 값은 왜 항상 false 인가요?
queryset = Notification.objects.filter( | ||
notification_read_log_set__read_by=self.request.user, | ||
).select_related( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self
에는 유저가 없어 보여요 ㅠㅠ
notifications = self.get_all_notifications() | ||
NotificationReadLog.objects.filter(notification__in=notifications, read_by=self.request.user).update(is_read=True) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notification과 notificationReadLog랑은 무슨 차이가 있나요??
3f00b35
to
c8b7d65
Compare
return [ | ||
notification | ||
for notification in notifications | ||
if NotificationReadLog.objects.filter( | ||
notification=notification, read_by=user_id, is_read=False | ||
).exists() | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 N+1 쿼리일 가능성이 높아 보이는데 시간 나면 리팩토링 하거나 TODO 체크해주세요 👍
return "실명" | ||
elif article.name_type == NameType.REGULAR: | ||
return "nickname" | ||
else: | ||
related_comment = None | ||
return "익명" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"실명", "nickname", "익명" 전부다 constant로 지정해서 사용해주세요!!!!
return "익명" | ||
|
||
def create_notification(self, comment: Comment) -> None: | ||
def notify_article_commented(_parent_article: Article, _comment: Comment): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변수에 왜 _가 들어있나요?
if comment.parent_comment: | ||
parent_comment = comment.parent_comment | ||
related_comment = parent_comment | ||
def get_display_name(self, article: Article, profile: int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거는 외부로 노출(domain 이나 다른 infra layer에서 사용할거 같아 보이는게 아닌)되지 않으면 함수명에 _ 붙여 주세요
related_comment = None | ||
return "익명" | ||
|
||
def create_notification(self, comment: Comment) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 transaction이 붙어야 할거 같아요 음... 근데 이거는 어려울 수도 있으니까 같이 한번 봐요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵~!
Create notification FastAPI.v2