Skip to content
This repository was archived by the owner on Mar 15, 2025. It is now read-only.

Commit 2159ff2

Browse files
kimminkyeudmdgpdisangwonsheep
authored
[FEAT] Batch 서버 랭킹 집계 추가 (#1151)
* [FEAT] 태그 순서 변경 로직 및 UI 추가, 익스텐션과 웹 서비스 상태 동기화 (#1142) * feat: 태그 이동 api 호출 함수 구현 * feat: cmdk에서 따온 fuzzy 알고리즘 적용 * feat: tag 순서 바꾸는 로직 적용 * refactor: css width를 상수로 관리 * design: drag handler 추가 * fix: 픽 정보 수정 응답 후, invalidateQueries 제거 * fix: tag 삭제 시에 바로 생성할 수 있게 변경 * feat: 익스텐션에서 삭제해도 웹에서 바로 적용되도록 변경 * feat: 익스텐션에 dnd-kit 의존성 추가 * feat: 익스텐션에서도 tag 이동 가능하게 변경 * chore: 익스텐션 버전 업 * Update baguni.test.api.deploy.yml * chore: postman ci/cd 배포 테스트 * Update baguni.test.api.deploy.yml * Update baguni.test.api.deploy.yml * Update baguni.test.api.deploy.yml * Update baguni.test.api.deploy.yml * Update baguni.test.api.deploy.yml * chore: discord webhook 알림 삭제 (#1145) * [feat] 링크 순위 집계 기능 이전 (Batch) (#1149) * [REFACTOR] 패키지명 rss 를 blog로 변경 (#1146) * refactor: 패키지 이름 변경 (rss --> blog) * chore: 로컬에서 otel 수집 기능 끄기 (otel export 에러 알림 발생 해결) * [FEAT] 배치 서버에 랭킹 집계 기능 추가 (#1147) * fix: 배치 랭킹 기능을 위한 큐 추가 * feat: 링크 통계 엔티티 / DB 테이블 추가 * feat: 배치 랭킹 소비자 구현 * fix: (코드 리뷰 반영) - repository를 linkDataHandler로 변경 * hotfix: @bean 추가 * hotfix: 큐 이름 수정 --------- Co-authored-by: dmdgpdi <33450285+dmdgpdi@users.noreply.github.com> Co-authored-by: Sangwon Yang <sangwonsheep@gmail.com>
1 parent 25a9bbc commit 2159ff2

74 files changed

Lines changed: 1594 additions & 284 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/baguni.prod.api.deploy.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,4 @@ jobs:
6969
7070
echo "restarting container..."
7171
docker compose down ${{ env.module-name }}
72-
docker compose up ${{ env.module-name }} -d
73-
74-
- name: Discord Webhook Notification
75-
uses: sarisia/actions-status-discord@v1.14.7
76-
if: always()
77-
with:
78-
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
79-
status: ${{ job.status }}
80-
title: 'TEST API SERVER DEPLOY'
81-
color: 0xff91a4
82-
url: 'https://github.com/sarisia/actions-status-discord'
83-
username: GitHub Actions
72+
docker compose up ${{ env.module-name }} -d

.github/workflows/baguni.prod.batch.deploy.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,4 @@ jobs:
6969
7070
echo "restarting container..."
7171
docker compose down ${{ env.module-name }}
72-
docker compose up ${{ env.module-name }} -d
73-
74-
- name: Discord Webhook Notification
75-
uses: sarisia/actions-status-discord@v1.14.7
76-
if: always()
77-
with:
78-
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
79-
status: ${{ job.status }}
80-
title: 'TEST BATCH SERVER DEPLOY'
81-
color: 0xff91a4
82-
url: 'https://github.com/sarisia/actions-status-discord'
83-
username: GitHub Actions
72+
docker compose up ${{ env.module-name }} -d

.github/workflows/baguni.prod.ranking.deploy.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,4 @@ jobs:
6868
6969
echo "restarting container..."
7070
docker compose down ${{ env.module-name }}
71-
docker compose up ${{ env.module-name }} -d
72-
73-
- name: Discord Webhook Notification
74-
uses: sarisia/actions-status-discord@v1.14.7
75-
if: always()
76-
with:
77-
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
78-
status: ${{ job.status }}
79-
title: 'TEST RANKING SERVER DEPLOY'
80-
color: 0xff91a4
81-
url: 'https://github.com/sarisia/actions-status-discord'
82-
username: GitHub Actions
71+
docker compose up ${{ env.module-name }} -d

.github/workflows/baguni.test.api.deploy.yml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,41 @@ jobs:
7171
docker compose down ${{ env.module-name }}
7272
docker compose up ${{ env.module-name }} -d
7373
74-
- name: Discord Webhook Notification
75-
uses: sarisia/actions-status-discord@v1.14.7
76-
if: always()
77-
with:
78-
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
79-
status: ${{ job.status }}
80-
title: 'TEST API SERVER DEPLOY'
81-
color: 0xff91a4
82-
url: 'https://github.com/sarisia/actions-status-discord'
83-
username: GitHub Actions
74+
# 서버가 완전히 기동될 때까지 대기하는 단계
75+
- name: Wait for API Server to be Ready
76+
run: |
77+
echo "🔍 Checking API server status..."
78+
attempt=0
79+
max_attempts=10
80+
81+
while true; do
82+
http_status=$(curl -o /dev/null -s -w "%{http_code}" https://v2.minlife.me)
83+
84+
if [ "$http_status" -ne 502 ]; then
85+
echo "✅ API Server responded Continuing..."
86+
break
87+
fi
88+
89+
attempt=$((attempt+1))
90+
if [ $attempt -ge $max_attempts ]; then
91+
echo "❌ API Server is still returning 502 after $max_attempts attempts. Exiting..."
92+
exit 1
93+
fi
94+
95+
echo "⏳ API Server still returning 502 (Bad Gateway), retrying in 5 seconds... (Attempt: $attempt)"
96+
sleep 5
97+
done
98+
99+
# Postman CLI 설치
100+
- name: Install Postman CLI
101+
run: |
102+
curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
103+
104+
# Postman 로그인
105+
- name: Login to Postman CLI
106+
run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}
107+
108+
# Postman Collection API Test
109+
- name: Run API tests
110+
run: |
111+
postman collection run "41803704-3caa037b-b45a-4dde-a57e-888df2b5c49e" -e "41803704-4000cf92-5c65-4a41-bc55-5eff8b50810c"

.github/workflows/baguni.test.batch.deploy.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,4 @@ jobs:
6969
7070
echo "restarting container..."
7171
docker compose down ${{ env.module-name }}
72-
docker compose up ${{ env.module-name }} -d
73-
74-
- name: Discord Webhook Notification
75-
uses: sarisia/actions-status-discord@v1.14.7
76-
if: always()
77-
with:
78-
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
79-
status: ${{ job.status }}
80-
title: 'TEST BATCH SERVER DEPLOY'
81-
color: 0xff91a4
82-
url: 'https://github.com/sarisia/actions-status-discord'
83-
username: GitHub Actions
72+
docker compose up ${{ env.module-name }} -d

.github/workflows/baguni.test.client.deploy.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,4 @@ jobs:
7979
docker compose up ${{ env.module-name }} -d
8080
8181
echo "docker - pruning images that passed 24h ..."
82-
docker image prune -af --filter "until=24h"
83-
84-
- name: Discord Webhook Notification
85-
uses: sarisia/actions-status-discord@v1.14.7
86-
if: always()
87-
with:
88-
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
89-
status: ${{ job.status }}
90-
title: 'TEST CLIENT DEPLOY'
91-
color: 0xff91a4
92-
url: 'https://github.com/sarisia/actions-status-discord'
93-
username: GitHub Actions
82+
docker image prune -af --filter "until=24h"

.github/workflows/baguni.test.ranking.deploy.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,4 @@ jobs:
6868
6969
echo "restarting container..."
7070
docker compose down ${{ env.module-name }}
71-
docker compose up ${{ env.module-name }} -d
72-
73-
- name: Discord Webhook Notification
74-
uses: sarisia/actions-status-discord@v1.14.7
75-
if: always()
76-
with:
77-
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
78-
status: ${{ job.status }}
79-
title: 'TEST RANKING SERVER DEPLOY'
80-
color: 0xff91a4
81-
url: 'https://github.com/sarisia/actions-status-discord'
82-
username: GitHub Actions
71+
docker compose up ${{ env.module-name }} -d

backend/baguni-api/src/main/java/baguni/BaguniApiApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55

6+
// 테스트 주석
67
@SpringBootApplication
78
public class BaguniApiApplication {
89
public static void main(String[] args) {

backend/baguni-batch/src/main/java/baguni/batch/domain/feed/service/FeedService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
import baguni.batch.domain.feed.dto.AtomFeed;
1717
import baguni.batch.domain.feed.dto.Article;
1818
import baguni.batch.domain.feed.dto.RssFeed;
19-
import baguni.batch.infrastructure.feed.BlogDataHandler;
19+
import baguni.domain.infrastructure.blog.BlogDataHandler;
2020
import baguni.common.event.events.LinkCreateEvent;
2121
import baguni.common.event.messenger.EventMessenger;
2222
import baguni.domain.infrastructure.link.LinkDataHandler;
2323
import baguni.domain.model.link.Link;
24-
import baguni.domain.model.rss.Blog;
24+
import baguni.domain.model.blog.Blog;
2525
import io.opentelemetry.instrumentation.annotations.WithSpan;
2626
import lombok.RequiredArgsConstructor;
2727
import lombok.extern.slf4j.Slf4j;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package baguni.batch.listener;
2+
3+
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
4+
import org.springframework.amqp.rabbit.annotation.RabbitListener;
5+
import org.springframework.stereotype.Component;
6+
7+
import baguni.common.config.RabbitmqConfig;
8+
import baguni.common.event.events.BookmarkCreateEvent;
9+
import baguni.common.event.events.LinkReadEvent;
10+
import baguni.domain.infrastructure.link.LinkDataHandler;
11+
import baguni.domain.infrastructure.link.LinkStatsRepository;
12+
import baguni.domain.model.link.LinkStats;
13+
import lombok.RequiredArgsConstructor;
14+
import lombok.extern.slf4j.Slf4j;
15+
16+
/**
17+
* RabbitMq Queue(PICK_RANKING) 에 들어오는 대로
18+
* 즉시 꺼내 집계에 반영하는 소비자 컴포넌트
19+
* */
20+
@Slf4j
21+
@Component
22+
@RequiredArgsConstructor
23+
@RabbitListener(queues = {RabbitmqConfig.QUEUE.LINK_RANKING_BATCH})
24+
public class LinkRankingEventListener {
25+
26+
private final LinkDataHandler linkDataHandler;
27+
28+
@RabbitHandler
29+
public void updateViewCount(LinkReadEvent event) {
30+
log.info("메시지 소비: topic {}, url {}", event.getTopicString(), event.getUrl());
31+
var date = event.getTime().toLocalDate();
32+
var url = event.getUrl();
33+
var linkStats = linkDataHandler
34+
.findLinkStats(date, url)
35+
.orElseGet(() -> new LinkStats(date, url));
36+
37+
linkStats.incrementViewCount();
38+
linkDataHandler.saveLinkStats(linkStats);
39+
}
40+
41+
@RabbitHandler
42+
public void updateBookmarkedCount(BookmarkCreateEvent event) {
43+
log.info("메시지 소비: topic {}, url {}", event.getTopicString(), event.getUrl());
44+
var date = event.getTime().toLocalDate();
45+
var url = event.getUrl();
46+
var linkStats = linkDataHandler
47+
.findLinkStats(date, url)
48+
.orElseGet(() -> new LinkStats(date, url));
49+
50+
linkStats.incrementBookmarkedCount();
51+
linkDataHandler.saveLinkStats(linkStats);
52+
}
53+
54+
/**
55+
* 매핑되지 않은 이벤트
56+
*/
57+
@RabbitHandler(isDefault = true)
58+
public void defaultMethod(Object object) {
59+
log.error("일치하는 이벤트 타입이 없습니다! {}", object.toString());
60+
}
61+
}

0 commit comments

Comments
 (0)