fix(publish): dashboard 'recent' = latest-updated 5, stable status order
dashboardSummary surfaced the earliest-scheduled packages as "recent" (it reused the queue's scheduledAt-asc sort); query updatedAt-desc instead. Build byStatus from an explicit ordered list since Set.of iteration order is undefined, so the dashboard renders DRAFT/READY/PUBLISHED consistently. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fd8403438e
commit
9edd4c5d97
@ -18,6 +18,8 @@ public class PublishService {
|
||||
private final PublishPackageRepository repository;
|
||||
|
||||
private static final Set<String> ALLOWED_STATUS = Set.of("DRAFT", "READY", "PUBLISHED");
|
||||
/** 대시보드 표시 순서가 고정되도록 명시적 순서 보장(Set.of 는 반복 순서 미정의). */
|
||||
private static final List<String> STATUS_ORDER = List.of("DRAFT", "READY", "PUBLISHED");
|
||||
|
||||
public PublishPackage getByVideo(Long channelVideoId) {
|
||||
return repository.findByChannelVideoId(channelVideoId).orElse(null);
|
||||
@ -55,14 +57,15 @@ public class PublishService {
|
||||
return repository.save(p);
|
||||
}
|
||||
|
||||
/** 대시보드용 발행 요약: 상태별 카운트 + 최근 5건. */
|
||||
/** 대시보드용 발행 요약: 상태별 카운트 + 최근 수정 5건. */
|
||||
public java.util.Map<String, Object> dashboardSummary() {
|
||||
java.util.Map<String, Long> byStatus = new java.util.LinkedHashMap<>();
|
||||
for (String s : ALLOWED_STATUS) {
|
||||
for (String s : STATUS_ORDER) {
|
||||
byStatus.put(s, repository.countByStatus(s));
|
||||
}
|
||||
List<PublishPackage> all = list(null);
|
||||
List<PublishPackage> recent = all.size() > 5 ? all.subList(0, 5) : all;
|
||||
// 최근 수정순으로 정렬해 상위 5건을 "최근" 으로 노출 (예약일 오름차순인 큐 정렬과 구분).
|
||||
List<PublishPackage> all = repository.findAllSorted(Sort.by(Sort.Order.desc("updatedAt")));
|
||||
List<PublishPackage> recent = all.size() > 5 ? List.copyOf(all.subList(0, 5)) : all;
|
||||
java.util.Map<String, Object> result = new java.util.LinkedHashMap<>();
|
||||
result.put("byStatus", byStatus);
|
||||
result.put("total", (long) all.size());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user