Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
public enum Category {
VOICE_PHISHING, SMISHING, MESSAGE_VOICE_PHISHING, ETC;

public static Category from(String input){
return switch (input){
case "보이스피싱" -> VOICE_PHISHING;
public static Category from(String input) {
return switch (input) {
case "보이스피싱", "보이스 피싱" -> VOICE_PHISHING;
case "스미싱" -> SMISHING;
case "메신저 피싱", "메신저피싱" -> MESSAGE_VOICE_PHISHING;
default -> ETC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
public class NewsSaveScheduler {
private final DaumNewsCrawler daumNewsCrawler;

public void crawlingForAdmin(){
String[] keywords = {"보이스피싱", "스미싱", "메신저 피싱", "몸캠"};
public void crawlingForAdmin() {
String[] keywords = {"보이스 피싱", "보이스피싱", "스미싱", "메신저 피싱", "몸캠"};
for (String keyword : keywords) {
Comment on lines +15 to 17
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

키워드 상수화 및 재사용: 중복 로직/오타 리스크를 줄이세요

관리자 수동 크롤링과 스케줄러에서 동일한 키워드 셋을 반복 선언하지 말고, 클래스 상수로 정의해 단일 소스로 관리하세요. 또한 배열 대신 불변 List 사용을 권장합니다.

아래 변경으로 crawlingForAdmin()에서 상수 재사용이 가능합니다.

-    public void crawlingForAdmin() {
-        String[] keywords = {"보이스 피싱", "보이스피싱", "스미싱", "메신저 피싱", "몸캠"};
-        for (String keyword : keywords) {
+    public void crawlingForAdmin() {
+        for (String keyword : KEYWORDS) {

그리고 클래스 상단에 다음을 추가하세요(선택 코드, 참고용):

// import java.util.List;
private static final List<String> KEYWORDS =
        List.of("보이스 피싱", "보이스피싱", "스미싱", "메신저 피싱", "몸캠");
🤖 Prompt for AI Agents
In
src/main/java/com/blockguard/server/domain/news/scheduler/NewsSaveScheduler.java
around lines 15 to 17, replace the locally declared String[] keywords with a
single immutable class-level constant to avoid duplication and typos: add a
private static final List<String> KEYWORDS = List.of(...); at the top of the
class (ensure java.util.List is imported) and update crawlingForAdmin() to
iterate over KEYWORDS instead of declaring a new array; use List.of to create an
unmodifiable list so other methods (like the admin manual crawler) can reuse the
same constant.

try {
daumNewsCrawler.fetchNewsFromDaum(keyword);
Expand All @@ -24,10 +24,10 @@ public void crawlingForAdmin(){
}

@Scheduled(cron = "0 0 4 * * *")
public void saveNewsArticles(){
public void saveNewsArticles() {
log.info("뉴스 크롤링 스케줄링 시작");

daumNewsCrawler.fetchNewsFromDaum("보이스피싱");
daumNewsCrawler.fetchNewsFromDaum("보이스 피싱");
daumNewsCrawler.fetchNewsFromDaum("스미싱");
daumNewsCrawler.fetchNewsFromDaum("메신저 피싱");
daumNewsCrawler.fetchNewsFromDaum("몸캠");
Expand Down