Skip to content

Commit 4cb4f22

Browse files
authored
Merge pull request #242 from boostcampwm-2024/feat/#211-reload-open-target-events
관리자 기능: 이벤트 오픈 스케줄 리프레시
2 parents 78c8e82 + 972b182 commit 4cb4f22

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

back/src/domains/booking/controller/booking.controller.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { Request } from 'express';
2626

2727
import { USER_STATUS } from '../../../auth/const/userStatus.const';
2828
import { SessionAuthGuard } from '../../../auth/guard/session.guard';
29-
import { AuthService } from '../../../auth/service/auth.service';
3029
import { SeatStatus } from '../const/seatStatus.enum';
3130
import { BookingAmountReqDto } from '../dto/bookingAmountReq.dto';
3231
import { BookingAmountResDto } from '../dto/bookingAmountRes.dto';
@@ -40,17 +39,18 @@ import { WaitingSseDto } from '../dto/waitingSse.dto';
4039
import { BookingSeatsService } from '../service/booking-seats.service';
4140
import { BookingService } from '../service/booking.service';
4241
import { InBookingService } from '../service/in-booking.service';
42+
import { OpenBookingService } from '../service/open-booking.service';
4343
import { WaitingQueueService } from '../service/waiting-queue.service';
4444

4545
@Controller('booking')
4646
export class BookingController {
4747
constructor(
4848
private readonly eventEmitter: EventEmitter2,
49-
private readonly authService: AuthService,
5049
private readonly bookingService: BookingService,
5150
private readonly inBookingService: InBookingService,
5251
private readonly bookingSeatsService: BookingSeatsService,
5352
private readonly waitingQueueService: WaitingQueueService,
53+
private readonly openBookingService: OpenBookingService,
5454
) {}
5555

5656
@UseGuards(SessionAuthGuard())
@@ -183,4 +183,16 @@ export class BookingController {
183183
const setSize = await this.inBookingService.setInBookingSessionsDefaultMaxSize(defaultMaxSize);
184184
return new InBookingSizeResDto(setSize);
185185
}
186+
187+
@Post('reload-open-target')
188+
@UseGuards(SessionAuthGuard(USER_STATUS.ADMIN))
189+
@ApiOperation({
190+
summary: 'ADMIN: 오픈 대상 이벤트 재확인',
191+
description: '오픈 대상 이벤트를 다시 확인하여 오픈한다.',
192+
})
193+
@ApiOkResponse({ description: '확인 및 오픈 완료' })
194+
@ApiUnauthorizedResponse({ description: '인증 실패' })
195+
async reloadOpenTarget() {
196+
await this.openBookingService.checkAndOpenReservations();
197+
}
186198
}

back/src/domains/booking/service/open-booking.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class OpenBookingService implements OnApplicationBootstrap {
3333
}
3434

3535
@Cron(CronExpression.EVERY_HOUR)
36-
private async checkAndOpenReservations() {
36+
async checkAndOpenReservations() {
3737
const events = await this.eventRepository.selectEvents();
3838
const openedEventIds = new Set(await this.getOpenedEventIds());
3939
const eventsToOpen = events.filter((event) => {
@@ -49,7 +49,7 @@ export class OpenBookingService implements OnApplicationBootstrap {
4949

5050
async getOpenedEventIds() {
5151
const keys = await this.redis.keys('open-booking:*:opened');
52-
const eventIds = keys.map((key) => parseInt(key.split(':')[2]));
52+
const eventIds = keys.map((key) => parseInt(key.split(':')[1]));
5353
return eventIds;
5454
}
5555

0 commit comments

Comments
 (0)