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

inv-54 참석 여부 조회 #6

Merged
merged 5 commits into from
Jul 26, 2024
Merged

inv-54 참석 여부 조회 #6

merged 5 commits into from
Jul 26, 2024

Conversation

9keyyyy
Copy link
Member

@9keyyyy 9keyyyy commented Jul 22, 2024

작업 내용

아래 항목 확인할 수 있는 쿼리 작성하였습니다.

  • 초대 응답 통계 (총 응답 수, 참석 예정 인원)
  • 응답 리스트
  • 응답 단건 조회



playground/invitation-response에서 확인 가능합니다. (neon dev branch 사용)

스크린샷 2024-07-22 오후 10 47 36

@9keyyyy 9keyyyy self-assigned this Jul 22, 2024
Copy link

linear bot commented Jul 22, 2024

Copy link
Collaborator

@bepyan bepyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

국희 이제 풀스택 개발자 해도 되겠다 👍🏻👍🏻
수고했습니다 🙌🏻

Comment on lines +33 to +34
queryKey: ["invitationResponseStats"],
queryFn: () => getInvitationResponseStats(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 이상하다 이건 서버 사이드에서 prefetch 안해도 괜찮나?
잘 동작하면 이 코멘트 무시해 주세요.

Comment on lines 23 to 30
const result = await db
.select({
totalResponses: sql`COUNT(*)`.as("total_responses"),
attendingCount:
sql`SUM(CASE WHEN ${invitationResponses.attendance} = true THEN 1 ELSE 0 END)`.as(
"attending_count",
),
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sql을 깡통으로 쓰기 보단 drizzle ORM이 제공해주는 helper를 활용하면,
더 안전하고 가독성이 좋을 것 같은데 한번 검토해 봐주세요!

sql을 쓰는게 편하다면 지금도 좋습니다~!

https://orm.drizzle.team/learn/guides/count-rows
https://orm.drizzle.team/docs/select#aggregations-helpers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오 활용해서 수정해볼게요~!

Comment on lines 10 to 37
export async function getAllInvitationResponses() {
return await db.select().from(invitationResponses);
}

export async function getInvitationResponseById(id: InvitationResponse["id"]) {
const responses = await db
.select()
.from(invitationResponses)
.where(eq(invitationResponses.id, id));
return responses[0];
}

export async function getInvitationResponseStats() {
const result = await db
.select({
totalResponses: sql`COUNT(*)`.as("total_responses"),
attendingCount:
sql`SUM(CASE WHEN ${invitationResponses.attendance} = true THEN 1 ELSE 0 END)`.as(
"attending_count",
),
})
.from(invitationResponses);

return {
totalResponses: Number(result[0].totalResponses),
attendingCount: Number(result[0].attendingCount),
};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaScript는 외부 리소스를 접근할 때 try catch를 감싸주어야 합니다
익숙치 않으시면 제가 나중에 감싸놓을게요 🐝

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 반영하겠습니당~~

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단 액션 호출하는 단(클라이언트 단)에서 try catch 묶어도 되니 추후 개선으로 가도 될 것 같아요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 넵넵! 화요일에 창완오빠랑도 클라이언트 단에서 처리하는 것으로 이야기했습니당

@WooWan
Copy link
Contributor

WooWan commented Jul 22, 2024

TypeScript도 낯설텐데 프론트까지.. 국희님께 프론트엔드 배우러 가겠습니ㄷ..r
감사합니다 ~

@xilucks
Copy link
Member

xilucks commented Jul 23, 2024

오예 고생하셨습니다 LGTM

Copy link
Member

@delphox60 delphox60 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프론트 개발자가 네명...!!
수고하셨습니다👍

@9keyyyy 9keyyyy merged commit 594c310 into main Jul 26, 2024
1 check passed
@9keyyyy 9keyyyy deleted the feat/inv-54 branch July 26, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants