-
Notifications
You must be signed in to change notification settings - Fork 3
π [λ²κ·Έ μμ ] : μ€μΌμ€λ¬ λ° λ©μμ§ μλ© μ€λ₯ μμ #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6f477cc
f5c983f
0c9a89a
a60e69e
64d4b83
f0800b9
bb06245
a64cfca
3c29fa2
5ea1d9c
ed6b77c
e3c30a4
758891e
dd7505b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Merge branch 'dev' of https://github.com/News-Deliver/Server into feat/sub/more | ||
| # Please enter a commit message to explain why this merge is necessary, | ||
| # especially if it merges an updated upstream into a topic branch. | ||
| # | ||
| # Lines starting with '#' will be ignored, and an empty message aborts | ||
| # the commit. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -81,7 +81,7 @@ public String getKakaoUserAccessToken(String refreshAccessToken, Long userId) { | |||||
| throw new KakaoException(ErrorCode.KAKAO_TOKEN_ACCESS_FAILED); | ||||||
| } | ||||||
|
|
||||||
| getNewsEsDocumentList(userId); | ||||||
| getNewsEsDocumentList_Fixed(userId); | ||||||
| return accessToken; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -96,7 +96,7 @@ public boolean sendKakaoMessage(String refreshAccessToken, Long userId) { | |||||
| try { | ||||||
| String accessToken = getKakaoUserAccessToken(refreshAccessToken, userId); | ||||||
|
|
||||||
| List<NewsEsDocument> newsList = getNewsEsDocumentList(userId); | ||||||
| List<NewsEsDocument> newsList = getNewsEsDocumentList_Fixed(userId); | ||||||
|
|
||||||
| //λ΄μ€κ° μμ λ λ°νν κ°μ κ³ λ―Ό ν΄λ³Ό κ². | ||||||
| if (newsList == null) new KakaoException(ErrorCode.NO_NEWS_DATA);; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. λ¬Έλ² μ€λ₯ μμ νμ μμΈλ₯Ό λμ§μ§ μκ³ μΈλ―Έμ½λ‘ μ΄ μ€λ³΅λμ΄ μμ΅λλ€. -if (newsList == null) new KakaoException(ErrorCode.NO_NEWS_DATA);;
+if (newsList == null) throw new KakaoException(ErrorCode.NO_NEWS_DATA);π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||
|
|
@@ -130,47 +130,51 @@ public boolean sendKakaoMessage(String refreshAccessToken, Long userId) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * μ¬μ©μμ Setting μ 보λ₯Ό κΈ°λ°μΌλ‘ ν€μλμ ν΄λΉνλ λ΄μ€λ₯Ό κ²μνμ¬ λ°νν©λλ€. | ||||||
| * λ΄μ€λ νμ€ν 리μ μ μ₯λλ©°, μ΅λ 5κ°κΉμ§ ν νλ¦ΏμΌλ‘ μ μ‘λ©λλ€. | ||||||
| /* | ||||||
| * μ¬μ©μμ ν€μλλ₯Ό λ°νμΌλ‘ λ΄μ€λ₯Ό κ²μνμ¬ λ¦¬μ€νΈλ‘ λ°ννλ λ©μλ | ||||||
| * | ||||||
| * @param userId μ¬μ©μ κ³ μ ID | ||||||
| * @return λ΄μ€ 리μ€νΈ {@code List<NewsEsDocument>}, ν€μλκ° μκ±°λ μ€λ₯ μ {@code null} | ||||||
| * Edit By : μ±μ΄ | ||||||
| * When : 2025-07-20 | ||||||
| * Why : νμ€ν 리 DBμ 2κ°μ μΈν μ΄ ν©μ³μ Έμ λ΄μ€κ° λ°μ‘λλ μ€λ₯ ν΄κ²° | ||||||
| * | ||||||
| * Deprecatedλ λ©μλλ νλ¨μ μ 리νμμ΅λλ€. | ||||||
| * | ||||||
| * @param userId μ μ μ κ³ μ λ²νΈ | ||||||
| * @return κ° μΈν μ λ§λ λ΄μ€ κΈ°μ¬ λ¦¬μ€4νΈ | ||||||
| */ | ||||||
| private List<NewsEsDocument> getNewsEsDocumentList(Long userId) { | ||||||
|
|
||||||
| //μ μ μ 보λ₯Ό κΈ°μ€μΌλ‘ Settigκ° κ°μ Έμ€κΈ° | ||||||
| private List<NewsEsDocument> getNewsEsDocumentList_Fixed(Long userId) { | ||||||
| List<SettingDTO> settings = settingService.getAllSettingsByUserId(userId); | ||||||
|
|
||||||
| List<String> keywords = new ArrayList<>(); | ||||||
| List<String> blockKeywords = new ArrayList<>(); | ||||||
| List<NewsEsDocument> totalNewsList = new ArrayList<>(); | ||||||
|
|
||||||
| for (SettingDTO setting : settings) { | ||||||
| log.info("μ ν κ° νμΈμ© μ½λ : " + setting.getSettingKeywords()); | ||||||
| log.info("μ ν μ μΈ νμΈμ© μ½λ : " + setting.getBlockKeywords()); | ||||||
|
|
||||||
| // ν€μλ리μ€νΈμ null κ° μ²΄ν¬ | ||||||
| if (setting.getSettingKeywords() != null) { | ||||||
| keywords.add(setting.getSettingKeywords().toString()); | ||||||
| List<String> keywords = setting.getSettingKeywords(); // μ: [μ΄μ¬λͺ ] | ||||||
| List<String> blockKeywords = setting.getBlockKeywords(); // μ: [νκ΅, μ€κ΅] | ||||||
|
|
||||||
| if (keywords == null || keywords.isEmpty()) { | ||||||
| log.warn("μΈν μ ν€μλκ° μμ΅λλ€. μ€ν΅ν©λλ€."); | ||||||
| continue; | ||||||
| } | ||||||
|
|
||||||
| blockKeywords.add(setting.getBlockKeywords().toString()); | ||||||
| } | ||||||
| List<NewsEsDocument> newsList = newsService.searchNews(keywords, blockKeywords); | ||||||
|
|
||||||
| if (keywords.isEmpty()) { | ||||||
| log.error("μ€μ λ ν€μλκ° μμ΅λλ€."); | ||||||
| throw new KakaoException(ErrorCode.SETTING_NOT_FOUND); | ||||||
| } | ||||||
| log.info(">> μΈν λΉ κ²μλ λ΄μ€ μ: {}", newsList.size()); | ||||||
|
|
||||||
| //ν€μλλ³ λ΄μ€ κ²μ | ||||||
| List<NewsEsDocument> newsList = newsService.searchNews(keywords, blockKeywords); | ||||||
| // μΈν λΉ 5κ°λ§ μ·¨νκ³ μΆλ€λ©΄ limit μ μ© | ||||||
| if (newsList.size() > 5) { | ||||||
| newsList = newsList.subList(0, 5); | ||||||
| } | ||||||
|
|
||||||
| // λ΄μ€ νμ€ν 리 μ μ₯ | ||||||
| saveHistory(newsList, List.of(setting)); // λ¨μΌ setting κΈ°μ€ | ||||||
|
|
||||||
| log.info("κ²μλ λ΄μ€ μ: {}", newsList.size()); | ||||||
| newsList.forEach(n -> log.info("λ΄μ€: {} - {}", n.getPublisher(), n.getSummary())); | ||||||
| totalNewsList.addAll(newsList); | ||||||
| } | ||||||
|
|
||||||
| // κ²μλ λ΄μ€λ₯Ό νμ€ν λ¦¬λ‘ λ³΄λ΄λ μ½λ | ||||||
| if (saveHistory(newsList, settings)) return null; | ||||||
| return newsList; | ||||||
| log.info("β μ 체 κ²μλ λ΄μ€ μ΄ν©: {}", totalNewsList.size()); | ||||||
| return totalNewsList; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -251,4 +255,50 @@ private boolean saveHistory(List<NewsEsDocument> newsList, List<SettingDTO> sett | |||||
| return saved; | ||||||
| } | ||||||
|
|
||||||
| // ======================= Deprecated ========================= | ||||||
| /* μ€λ₯ λ°μ */ | ||||||
|
|
||||||
| /** | ||||||
| * μ¬μ©μμ Setting μ 보λ₯Ό κΈ°λ°μΌλ‘ ν€μλμ ν΄λΉνλ λ΄μ€λ₯Ό κ²μνμ¬ λ°νν©λλ€. | ||||||
| * λ΄μ€λ νμ€ν 리μ μ μ₯λλ©°, μ΅λ 5κ°κΉμ§ ν νλ¦ΏμΌλ‘ μ μ‘λ©λλ€. | ||||||
| * | ||||||
| * @param userId μ¬μ©μ κ³ μ ID | ||||||
| * @return λ΄μ€ 리μ€νΈ {@code List<NewsEsDocument>}, ν€μλκ° μκ±°λ μ€λ₯ μ {@code null} | ||||||
| */ | ||||||
| // private List<NewsEsDocument> getNewsEsDocumentList(Long userId) { | ||||||
| // | ||||||
| // //μ μ μ 보λ₯Ό κΈ°μ€μΌλ‘ Settigκ° κ°μ Έμ€κΈ° | ||||||
| // List<SettingDTO> settings = settingService.getAllSettingsByUserId(userId); | ||||||
| // | ||||||
| // List<String> keywords = new ArrayList<>(); | ||||||
| // List<String> blockKeywords = new ArrayList<>(); | ||||||
| // | ||||||
| // for (SettingDTO setting : settings) { | ||||||
| // log.info("μ ν κ° νμΈμ© μ½λ : " + setting.getSettingKeywords()); | ||||||
| // log.info("μ ν μ μΈ νμΈμ© μ½λ : " + setting.getBlockKeywords()); | ||||||
| // | ||||||
| // // ν€μλ리μ€νΈμ null κ° μ²΄ν¬ | ||||||
| // if (setting.getSettingKeywords() != null) { | ||||||
| // keywords.add(setting.getSettingKeywords().toString()); | ||||||
| // } | ||||||
| // | ||||||
| // blockKeywords.add(setting.getBlockKeywords().toString()); | ||||||
| // } | ||||||
| // | ||||||
| // if (keywords.isEmpty()) { | ||||||
| // log.error("μ€μ λ ν€μλκ° μμ΅λλ€."); | ||||||
| // throw new KakaoException(ErrorCode.SETTING_NOT_FOUND); | ||||||
| // } | ||||||
| // | ||||||
| // //ν€μλλ³ λ΄μ€ κ²μ | ||||||
| // List<NewsEsDocument> newsList = newsService.searchNews(keywords, blockKeywords); | ||||||
| // | ||||||
| // log.info("κ²μλ λ΄μ€ μ: {}", newsList.size()); | ||||||
| // newsList.forEach(n -> log.info("λ΄μ€: {} - {}", n.getPublisher(), n.getSummary())); | ||||||
| // | ||||||
| // // κ²μλ λ΄μ€λ₯Ό νμ€ν λ¦¬λ‘ λ³΄λ΄λ μ½λ | ||||||
| // if (saveHistory(newsList, settings)) return null; | ||||||
| // return newsList; | ||||||
| // } | ||||||
|
|
||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,8 @@ public ElasticsearchClient elasticsearchClient() { | |
| // HTTP κΈ°λ° Low-level ν΄λΌμ΄μΈνΈ κ΅¬μ± | ||
| RestClient restClient = RestClient.builder( | ||
| new HttpHost("elasticsearch", 9200) | ||
| // μ±μ΄ λ‘μ»¬μ© μμ Host | ||
| //new HttpHost("localhost", 9200) | ||
| ).build(); | ||
|
Comment on lines
50
to
53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Verification agent β Verification inconclusiveνΈμ€νΈ/ν¬νΈ νλμ½λ© λμ νκ²½ μ€μ μΌλ‘ μΈλΆννμΈμ μμ diff: +@Value("${elasticsearch.host:elasticsearch}")
+private String esHost;
+
+@Value("${elasticsearch.port:9200}")
+private int esPort;
...
-RestClient restClient = RestClient.builder(
- new HttpHost("elasticsearch", 9200)
- // μ±μ΄ λ‘μ»¬μ© μμ Host
- //new HttpHost("localhost", 9200)
-).build();
+RestClient restClient = RestClient.builder(
+ new HttpHost(esHost, esPort)
+).build();μ΄λ κ² νλ©΄ νλ‘νμΌλ³ νΈμ€νΈ/ν¬νΈ νλμ½λ©μ μ κ±°νκ³ μ€μ νμΌλ‘ μΈλΆννμΈμ νμ¬ λ€μκ³Ό κ°μ΄ // ν΄λμ€ νλμ μΆκ°
+ @Value("${elasticsearch.host:elasticsearch}")
+ private String esHost;
+
+ @Value("${elasticsearch.port:9200}")
+ private int esPort;
@Bean
public RestClient elasticsearchClient() {
- RestClient restClient = RestClient.builder(
- new HttpHost("elasticsearch", 9200)
- // μ±μ΄ λ‘μ»¬μ© μμ Host
- //new HttpHost("localhost", 9200)
- ).build();
+ RestClient restClient = RestClient.builder(
+ new HttpHost(esHost, esPort)
+ ).build();
return restClient;
}β π€ Prompt for AI Agents |
||
|
|
||
| // LocalDateTime μ§λ ¬ν μ§μ λ° ISO ν¬λ§· μ§μ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
μμ ν΄κ²°μ± λμ κ·Όλ³Έ μμΈ ν΄κ²° νμ
μμ μ£ΌμμΌλ‘ μΊμ± λ¬Έμ λ₯Ό ν΄κ²°νλ κ²λ³΄λ€λ κ·Όλ³Έ μμΈμ νμ νκ³ μ μ ν ν΄κ²°μ± μ μ μ©νλ κ²μ΄ μ’κ² μ΅λλ€. νμ¬ μ£Όμλ§μΌλ‘λ μ΄λ€ μΊμ± λ¬Έμ κ° λ°μνλμ§ λͺ ννμ§ μμ΅λλ€.
λ€μκ³Ό κ°μ μ‘°μΉλ₯Ό κΆμ₯ν©λλ€:
μ΄ μμ ν΄κ²°μ± μ μ μ ν μμ μΌλ‘ κ΅μ²΄νλ μ½λλ₯Ό μμ±ν΄λ릴κΉμ?
π€ Prompt for AI Agents