Skip to content

Commit b8840c1

Browse files
Merge pull request #498 from Podo-Store/develop
[FIX] 조회수 정렬 및 동기화 타이밍 조정
2 parents 5408d1a + d47563a commit b8840c1

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

src/main/java/PodoeMarket/podoemarket/product/service/ProductService.java

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.io.OutputStream;
3838
import java.net.URL;
3939
import java.time.LocalDateTime;
40-
import java.util.Comparator;
4140
import java.util.List;
4241
import java.util.UUID;
4342
import java.util.zip.ZipEntry;
@@ -61,37 +60,21 @@ public List<ScriptListResponseDTO.ProductListDTO> getPlayList(int page, UserEnti
6160
try {
6261
List<ProductStatus> validStatuses = List.of(ProductStatus.PASS, ProductStatus.RE_WAIT, ProductStatus.RE_PASS);
6362

64-
// POPULAR(조회수 기준 정렬)는 Java단에서 처리
65-
if (sortType == ProductSortType.POPULAR) {
66-
List<ProductEntity> plays = productRepo.findAllValidPlays(
67-
playType,
68-
validStatuses,
69-
PageRequest.of(page, pageSize, Sort.unsorted()) // 정렬 직접 처리
70-
);
71-
72-
return plays.stream()
73-
.map(play -> getListDTO(userInfo, play))
74-
.sorted(Comparator.comparingLong(ScriptListResponseDTO.ProductListDTO::getViewCount).reversed())
75-
.limit(pageSize)
76-
.toList();
77-
} else {
78-
Sort sort = createProductSort(sortType);
79-
List<ProductEntity> plays = productRepo.findAllValidPlays(
80-
playType,
81-
validStatuses,
82-
PageRequest.of(page, pageSize, sort)
83-
);
84-
85-
return plays.stream()
86-
.map(play -> getListDTO(userInfo, play))
87-
.toList();
88-
}
63+
Sort sort = createProductSort(sortType);
64+
List<ProductEntity> plays = productRepo.findAllValidPlays(
65+
playType,
66+
validStatuses,
67+
PageRequest.of(page, pageSize, sort)
68+
);
69+
70+
return plays.stream()
71+
.map(play -> getListDTO(userInfo, play))
72+
.toList();
8973
} catch (Exception e) {
9074
throw new RuntimeException("작품 목록 조회 실패", e);
9175
}
9276
}
9377

94-
9578
public ProductEntity getProduct(UUID id) {
9679
try {
9780
return productRepo.findById(id);

src/main/java/PodoeMarket/podoemarket/service/ViewCountService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public Long getProductViewCount(UUID productId) {
4545
return base + delta;
4646
}
4747

48-
// 6시간마다 Redis에서 MySQL에 백업
49-
@Scheduled(cron = "0 0 0,6,12,18 * * *") // 매일 0시, 6시, 12시, 18시에 실행
48+
// 1시간마다 Redis에서 MySQL에 백업
49+
@Scheduled(cron = "0 0 * * * *")
5050
@Transactional
5151
public void flushDeltaToDB() {
5252
log.info("작품 조회수 델타 동기화 시작");

0 commit comments

Comments
 (0)