Skip to content

Commit 20876f7

Browse files
authored
[HOTFIX] 260218
[HOTFIX] 260218
2 parents c5cbe20 + b5befcc commit 20876f7

12 files changed

Lines changed: 224 additions & 97 deletions

File tree

.github/workflows/dev-cd.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
token: ${{ secrets.PACKAGE_DELETE_TOKEN }}
7777
image-names: solid-connection-dev
7878
delete-untagged: true
79-
keep-n-tags: 5
79+
keep-n-tags: 2
8080
account-type: org
8181
org-name: ${{ github.repository_owner }}
8282
cut-off: '7 days ago UTC'
@@ -123,28 +123,28 @@ jobs:
123123
export OWNER_LOWERCASE=$(echo "${{ github.repository_owner }}" | tr "[:upper:]" "[:lower:]")
124124
export IMAGE_TAG_ONLY="${{ needs.build-and-push.outputs.image_tag }}"
125125
export FULL_IMAGE_NAME="ghcr.io/${OWNER_LOWERCASE}/solid-connection-dev:${IMAGE_TAG_ONLY}"
126-
127-
# 2. GHCR 로그인 & Pull
126+
export IMAGE_NAME_BASE="ghcr.io/${OWNER_LOWERCASE}/solid-connection-dev"
127+
128+
# 2. Pull 전 정리 (디스크 공간 확보)
129+
echo "Cleaning up old tagged images (keeping last 2)..."
130+
docker images "${IMAGE_NAME_BASE}" --format "{{.Tag}}" | \
131+
sort -r | \
132+
tail -n +3 | \
133+
xargs -I {} docker rmi "${IMAGE_NAME_BASE}:{}" || true
134+
135+
echo "Pruning dangling images..."
136+
docker image prune -f
137+
138+
# 3. GHCR 로그인 & Pull
128139
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
129140
echo "Pulling new image: $FULL_IMAGE_NAME"
130141
docker pull $FULL_IMAGE_NAME
131-
132-
# 3. Spring Boot 앱 재시작
142+
143+
# 4. Spring Boot 앱 재시작
133144
echo "Restarting Docker Compose with tag: $IMAGE_TAG_ONLY"
134145
cd /home/${{ secrets.DEV_USERNAME }}/solid-connection-dev
135146
docker compose -f docker-compose.dev.yml down || true
136147
OWNER_LOWERCASE=$OWNER_LOWERCASE IMAGE_TAG=$IMAGE_TAG_ONLY docker compose -f docker-compose.dev.yml up -d
137-
138-
# 4. 정리 작업
139-
echo "Pruning dangling images..."
140-
docker image prune -f
141-
142-
echo "Cleaning up old tagged images (keeping last 5)..."
143-
IMAGE_NAME_BASE="ghcr.io/${OWNER_LOWERCASE}/solid-connection-dev"
144-
docker images "${IMAGE_NAME_BASE}" --format "{{.Tag}}" | \
145-
sort -r | \
146-
tail -n +6 | \
147-
xargs -I {} docker rmi "${IMAGE_NAME_BASE}:{}" || true
148-
148+
149149
echo "Deployment finished successfully."
150-
'
150+
'

.github/workflows/prod-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,4 @@ jobs:
155155
# 6. 정리
156156
docker image prune -f
157157
echo "Deployment finished successfully."
158-
'
158+
'

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ dependencies {
5757

5858
// Test
5959
testImplementation 'org.springframework.boot:spring-boot-starter-test'
60-
testImplementation 'org.testcontainers:testcontainers'
61-
testImplementation 'org.testcontainers:junit-jupiter'
62-
testImplementation 'org.testcontainers:mysql'
60+
testImplementation 'org.testcontainers:testcontainers:2.0.2'
61+
testImplementation 'org.testcontainers:testcontainers-junit-jupiter:2.0.2'
62+
testImplementation 'org.testcontainers:testcontainers-mysql:2.0.2'
6363
testImplementation 'org.projectlombok:lombok'
6464
testAnnotationProcessor 'org.projectlombok:lombok'
6565
testImplementation 'org.awaitility:awaitility:4.2.0'

src/main/java/com/example/solidconnection/news/controller/NewsController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ public class NewsController {
3535

3636
// todo: 추후 Slice 적용
3737
@GetMapping
38-
public ResponseEntity<NewsListResponse> findNewsBySiteUserId(
38+
public ResponseEntity<NewsListResponse> findNews(
3939
@AuthorizedUser(required = false) Long siteUserId,
40-
@RequestParam(value = "author-id") Long authorId
40+
@RequestParam(value = "author-id", required = false) Long authorId
4141
) {
42-
NewsListResponse newsListResponse = newsQueryService.findNewsByAuthorId(siteUserId, authorId);
42+
NewsListResponse newsListResponse = newsQueryService.findNews(siteUserId, authorId);
4343
return ResponseEntity.ok(newsListResponse);
4444
}
4545

src/main/java/com/example/solidconnection/news/repository/NewsRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
public interface NewsRepository extends JpaRepository<News, Long>, NewsCustomRepository {
99

10+
List<News> findAllByOrderByUpdatedAtDesc();
11+
1012
List<News> findAllBySiteUserIdOrderByUpdatedAtDesc(long siteUserId);
1113

1214
void deleteAllBySiteUserId(long siteUserId);

src/main/java/com/example/solidconnection/news/repository/custom/NewsCustomRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
public interface NewsCustomRepository {
77

88
List<NewsResponse> findNewsByAuthorIdWithLikeStatus(long authorId, Long siteUserId);
9+
10+
List<NewsResponse> findAllNewsWithLikeStatus(Long siteUserId);
911
}

src/main/java/com/example/solidconnection/news/repository/custom/NewsCustomRepositoryImpl.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ public class NewsCustomRepositoryImpl implements NewsCustomRepository {
1212

1313
private final EntityManager entityManager;
1414

15+
@Override
16+
public List<NewsResponse> findAllNewsWithLikeStatus(Long siteUserId) {
17+
String jpql = """
18+
SELECT new com.example.solidconnection.news.dto.NewsResponse(
19+
n.id,
20+
n.title,
21+
n.description,
22+
n.thumbnailUrl,
23+
n.url,
24+
CASE WHEN ln.id IS NOT NULL THEN true ELSE false END,
25+
n.updatedAt
26+
)
27+
FROM News n
28+
LEFT JOIN LikedNews ln ON n.id = ln.newsId AND ln.siteUserId = :siteUserId
29+
ORDER BY n.updatedAt DESC
30+
""";
31+
32+
return entityManager.createQuery(jpql, NewsResponse.class)
33+
.setParameter("siteUserId", siteUserId)
34+
.getResultList();
35+
}
36+
1537
@Override
1638
public List<NewsResponse> findNewsByAuthorIdWithLikeStatus(long authorId, Long siteUserId) {
1739
String jpql = """

src/main/java/com/example/solidconnection/news/service/NewsQueryService.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.solidconnection.news.service;
22

3+
import com.example.solidconnection.news.domain.News;
34
import com.example.solidconnection.news.dto.NewsListResponse;
45
import com.example.solidconnection.news.dto.NewsResponse;
56
import com.example.solidconnection.news.repository.NewsRepository;
@@ -15,19 +16,24 @@ public class NewsQueryService {
1516
private final NewsRepository newsRepository;
1617

1718
@Transactional(readOnly = true)
18-
public NewsListResponse findNewsByAuthorId(Long siteUserId, long authorId) {
19-
// 로그인하지 않은 경우
19+
public NewsListResponse findNews(Long siteUserId, Long authorId) {
2020
if (siteUserId == null) {
21-
List<NewsResponse> newsResponseList = newsRepository.findAllBySiteUserIdOrderByUpdatedAtDesc(authorId)
22-
.stream()
21+
List<NewsResponse> newsResponseList = findNewsEntities(authorId).stream()
2322
.map(news -> NewsResponse.of(news, null))
2423
.toList();
2524
return NewsListResponse.from(newsResponseList);
2625
}
2726

28-
// 로그인한 경우
29-
List<NewsResponse> newsResponseList = newsRepository.findNewsByAuthorIdWithLikeStatus(authorId, siteUserId);
30-
27+
List<NewsResponse> newsResponseList = (authorId == null)
28+
? newsRepository.findAllNewsWithLikeStatus(siteUserId)
29+
: newsRepository.findNewsByAuthorIdWithLikeStatus(authorId, siteUserId);
3130
return NewsListResponse.from(newsResponseList);
3231
}
32+
33+
private List<News> findNewsEntities(Long authorId) {
34+
if (authorId == null) {
35+
return newsRepository.findAllByOrderByUpdatedAtDesc();
36+
}
37+
return newsRepository.findAllBySiteUserIdOrderByUpdatedAtDesc(authorId);
38+
}
3339
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ALTER TABLE language_requirement
2+
MODIFY COLUMN language_test_type ENUM(
3+
'CEFR',
4+
'DALF',
5+
'DELF',
6+
'DELE',
7+
'DUOLINGO',
8+
'IELTS',
9+
'JLPT',
10+
'NEW_HSK',
11+
'TCF',
12+
'TEF',
13+
'TOEFL_IBT',
14+
'TOEFL_ITP',
15+
'TOEIC',
16+
'ETC'
17+
) NOT NULL;

src/test/java/com/example/solidconnection/database/FlywayMigrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.springframework.context.ConfigurableApplicationContext;
99
import org.springframework.test.context.ContextConfiguration;
1010
import org.springframework.test.context.TestPropertySource;
11-
import org.testcontainers.containers.MySQLContainer;
11+
import org.testcontainers.mysql.MySQLContainer;
1212

1313
@SpringBootTest
1414
@ContextConfiguration(initializers = {RedisTestContainer.class, FlywayMigrationTest.FlywayMySQLInitializer.class})
@@ -19,7 +19,7 @@
1919
})
2020
class FlywayMigrationTest {
2121

22-
private static final MySQLContainer<?> CONTAINER = new MySQLContainer<>("mysql:8.0")
22+
private static final MySQLContainer CONTAINER = new MySQLContainer("mysql:8.0")
2323
.withDatabaseName("flyway_test")
2424
.withUsername("flyway_user")
2525
.withPassword("flyway_password");

0 commit comments

Comments
 (0)