diff --git a/be/src/restaurant/restaurant.module.ts b/be/src/restaurant/restaurant.module.ts index 27c2f1af..b4b69490 100644 --- a/be/src/restaurant/restaurant.module.ts +++ b/be/src/restaurant/restaurant.module.ts @@ -5,10 +5,11 @@ import { RestaurantService } from "./restaurant.service"; import { RestaurantRepository } from "./restaurant.repository"; import { UserModule } from "src/user/user.module"; import { ReviewModule } from "src/review/review.module"; +import { ScheduleModule } from '@nestjs/schedule'; @Module({ - imports: [AuthModule, UserModule, ReviewModule], + imports: [AuthModule, UserModule, ReviewModule, ScheduleModule.forRoot(),], controllers: [RestaurantController], providers: [RestaurantService, RestaurantRepository], }) -export class RestaurantModule {} +export class RestaurantModule { } diff --git a/be/src/restaurant/restaurant.service.ts b/be/src/restaurant/restaurant.service.ts index e2a580de..dea458f8 100644 --- a/be/src/restaurant/restaurant.service.ts +++ b/be/src/restaurant/restaurant.service.ts @@ -9,19 +9,16 @@ import { UserRepository } from "src/user/user.repository"; import { ReviewRepository } from "src/review/review.repository"; import { LocationDto } from "./dto/location.dto"; import { AwsService } from "src/aws/aws.service"; +import { Cron } from "@nestjs/schedule"; const key = process.env.API_KEY; @Injectable() -export class RestaurantService implements OnModuleInit { - onModuleInit() { +export class RestaurantService { + + @Cron('0 0 2 * * *') + handleCron() { this.updateRestaurantsFromSeoulData(); - setInterval( - () => { - this.updateRestaurantsFromSeoulData(); - }, - 1000 * 60 * 60 * 24 * 3 - ); } constructor(