Skip to content

Commit

Permalink
feat : setInterval 업데이트 주기를 Cron으로 변경 #35
Browse files Browse the repository at this point in the history
  • Loading branch information
GeunH committed Dec 7, 2023
1 parent 2ec48f3 commit 5a4ffe7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 3 additions & 2 deletions be/src/restaurant/restaurant.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
13 changes: 5 additions & 8 deletions be/src/restaurant/restaurant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5a4ffe7

Please sign in to comment.