Skip to content

Commit

Permalink
Merge pull request #75 from NewsFit-jolp/fix/zoned-date-tiem
Browse files Browse the repository at this point in the history
Fix/zoned date tiem
  • Loading branch information
k000927 authored Nov 18, 2024
2 parents 1b2982a + 1e53a72 commit 6c5a7f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,4 @@ public String recommendArticles(@RequestParam(value = "page", required = false,
public SuccessResponse<List<GetArticles>> getHeadLine() throws JsonProcessingException {
return SuccessResponse.success(articleService.getHeadLine());
}


@GetMapping("/test/{articleId}")
public String getArticleTest(@PathVariable("articleId") String articleId){
return articleService.getTest(articleId);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;

@Component
Expand All @@ -22,9 +22,9 @@ public class ArticleCleanupScheduler {
private final ArticleRepository articleRepository;
private final RecommenderUtils recommenderUtils;

@Scheduled(cron = "0 0 4 * * ?")
@Scheduled(cron = "0 0 4 * * ?", zone = "Asia/Seoul")
public void cleanup() throws JsonProcessingException {
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
LocalDateTime yesterday = ZonedDateTime.now(ZoneId.of("Asia/Seoul")).minusDays(1).toLocalDateTime();
List<Article> oldArticles = articleRepository.findOldArticle(yesterday);
for (Article oldArticle : oldArticles) {
recommenderUtils.removeOldArticles(oldArticle.getArticleId());
Expand Down

0 comments on commit 6c5a7f1

Please sign in to comment.