-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix/#53 recommend
- Loading branch information
Showing
22 changed files
with
219 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
src/main/java/com/example/newsfit/domain/article/service/ArticleCleanupScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
package com.example.newsfit.domain.article.service; | ||
|
||
import com.example.newsfit.domain.article.entity.Article; | ||
import com.example.newsfit.domain.article.repository.ArticleRepository; | ||
import com.example.newsfit.global.util.RecommenderUtils; | ||
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.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ArticleCleanupScheduler { | ||
|
||
@Autowired | ||
private final ArticleRepository articleRepository; | ||
private final RecommenderUtils recommenderUtils; | ||
|
||
@Scheduled(cron = "0 0 4 * * ?") | ||
public void cleanup() { | ||
public void cleanup() throws JsonProcessingException { | ||
LocalDateTime yesterday = LocalDateTime.now().minusDays(1); | ||
articleRepository.deleteOldArticle(yesterday); | ||
List<Article> oldArticles = articleRepository.findOldArticle(yesterday); | ||
for (Article oldArticle : oldArticles) { | ||
recommenderUtils.removeOldArticles(oldArticle.getArticleId()); | ||
articleRepository.delete(oldArticle); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 9 additions & 3 deletions
12
src/main/java/com/example/newsfit/domain/member/dto/GetPreferredCategories.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
package com.example.newsfit.domain.member.dto; | ||
|
||
import com.amazonaws.services.dynamodbv2.xspec.S; | ||
import com.example.newsfit.domain.article.entity.Category; | ||
import com.example.newsfit.domain.member.entity.*; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public record GetPreferredCategories( | ||
@Schema(description = "선호 카테고리", example = "IT, Technology, Sports") List<Category> preferredCategories | ||
|
||
@Schema(description = "선호 카테고리", example = "IT, Technology, Sports") List<String> preferredCategories | ||
) { | ||
public static GetPreferredCategories of(Member member) { | ||
return new GetPreferredCategories(member.getPreferredCategories()); | ||
List<Category> preferredCategories = member.getPreferredCategories(); | ||
List<String> displayName = new ArrayList<>(); | ||
for (Category category : preferredCategories) { | ||
displayName.add(category.toString()); | ||
} | ||
return new GetPreferredCategories(displayName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/example/newsfit/domain/member/entity/Gender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.example.newsfit.domain.member.entity; | ||
|
||
public enum Gender { | ||
Male, Female | ||
MALE, FEMALE, UNKNOWN; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.