Skip to content

Commit

Permalink
✨ [Feat]: reservation 생성 조건 변경 (#124)
Browse files Browse the repository at this point in the history
- reservation 생성 조건을
  진행중(request-accept-mentee_checked-mentee_feedback)상태로
  확장했습니다.
- transaction 내에서 처리되기때문에 count와 같은 집계함수의 속도를
  높이는 것이 최우선이라고 생각했습니다.
- mentorId, menteeId, status에 index를 생성해 빠르게 집계할 수 있도록
  변경했습니다.
  • Loading branch information
koreanddinghwan authored Oct 1, 2023
1 parent 5ae2685 commit 9cf218e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions prisma/migrations/20231001120336_118/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- CreateIndex
CREATE INDEX `reservations_mentor_id_mentee_id_status_idx` ON `reservations`(`mentor_id`, `mentee_id`, `status`);
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ model Reservation {
menteeFeedback MenteeFeedback?
cancelReason CancelReason?
@@index([mentorId, menteeId, status])
@@map("reservations")
}

Expand Down
7 changes: 6 additions & 1 deletion src/database/repository/reservation.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ export class ReservationRepository {
where: {
mentorId: mentorId,
menteeId: menteeId,
OR: [{ status: 'ACCEPT' }, { status: 'REQUEST' }],
OR: [
{ status: ReservationStatus.REQUEST },
{ status: ReservationStatus.ACCEPT },
{ status: ReservationStatus.MENTEE_CHECKED },
{ status: ReservationStatus.MENTEE_FEEDBACK },
],
},
});
if (existMentoringCount !== 0)
Expand Down

0 comments on commit 9cf218e

Please sign in to comment.