Skip to content

Commit

Permalink
Merge pull request #26 from team-REDDI/dev
Browse files Browse the repository at this point in the history
dev to main
  • Loading branch information
itsme-shawn authored Jan 22, 2024
2 parents 96ba18f + d7c7170 commit bdc6310
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
script: |
cd /home/ubuntu/
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 533267191976.dkr.ecr.ap-northeast-2.amazonaws.com
## docker-compose 실행
sudo chmod 666 /var/run/docker.sock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableJpaAuditing
@EnableScheduling
@SpringBootApplication
public class ReddiServerApplication {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public class NotionController {

private final NotionService notionService;

@Hidden
@Operation(summary = "[테스트용] 노션 api 호출해서 자체 DB 갱신")
@Operation(summary = "[수동갱신] 노션 api 호출해서 DB 갱신")
@GetMapping("/update")
public ApiResponse<?> getNotionData() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.reddiserver.scheduler;

import com.example.reddiserver.common.ApiResponse;
import com.example.reddiserver.service.NotionService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class NotionDataFetchScheduler {

private final NotionService notionService;

@Scheduled(cron = "0 */30 * * * *") // 30분마다 실행
public void fetchNotionData() {
// DB init
notionService.deleteAll();

List<String> brandPageIds = notionService.getBrandPageIds();
notionService.getBrandPageContents(brandPageIds);

List<String> marketingPageIds = notionService.getMarketingPageIds();
notionService.getMarketingPageContents(marketingPageIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public NotionService(WebClient.Builder webClientBuilder, @Value("${notion.api.ke
// brand, brand_tags 테이블 초기화
@Transactional
public void deleteAll() {
postTagRepository.deleteAll();
postRepository.deleteAll();
brandTagRepository.deleteAll();
brandRepository.deleteAll();

Expand Down

0 comments on commit bdc6310

Please sign in to comment.