From 277e99a482f2adcf842327ff16b99d153a1a4a68 Mon Sep 17 00:00:00 2001 From: swa07016 Date: Sun, 7 Jan 2024 17:03:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:bug:=20Fix:=20=EB=B8=8C=EB=A6=AC=ED=95=91?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=88=9C=EC=9C=84?= =?UTF-8?q?=20=EB=B2=84=EA=B7=B8=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/BriefingCustomRepositoryImpl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java b/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java index b1b75d4..8eeefdb 100644 --- a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java +++ b/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java @@ -1,5 +1,6 @@ package briefing.briefing.domain.repository; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -9,6 +10,9 @@ import org.springframework.stereotype.Repository; import com.querydsl.core.Tuple; +import com.querydsl.core.types.dsl.DateTemplate; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQueryFactory; import briefing.briefing.domain.Briefing; @@ -61,6 +65,11 @@ public List findTop10ByTypeOrderByCreatedAtDesc(BriefingType type) { QBriefing briefing = QBriefing.briefing; QScrap scrap = QScrap.scrap; + DateTimePath dateTime = briefing.createdAt; + DateTemplate date = + Expressions.dateTemplate( + LocalDate.class, "DATE_FORMAT({0}, {1})", dateTime, "%Y-%m-%d"); + List results = queryFactory .select(briefing, scrap.count()) @@ -69,7 +78,7 @@ public List findTop10ByTypeOrderByCreatedAtDesc(BriefingType type) { .on(scrap.briefing.eq(briefing)) .where(briefing.type.eq(type)) .groupBy(briefing) - .orderBy(briefing.createdAt.desc()) + .orderBy(date.desc(), briefing.ranks.desc()) .limit(10) .fetch(); From 66ae90e8a0475afd860ace9815d7c1e1d55082a5 Mon Sep 17 00:00:00 2001 From: swa07016 Date: Sun, 7 Jan 2024 17:23:03 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:recycle:=20Refactor:=20=EC=95=A0=ED=94=8C?= =?UTF-8?q?=EB=A6=AC=EC=BC=80=EC=9D=B4=EC=85=98=EB=8B=A8=20=EC=97=AD?= =?UTF-8?q?=EC=88=9C=20=EC=A0=95=EB=A0=AC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../briefing/application/strategy/BriefingV1QueryStrategy.java | 2 -- .../briefing/application/strategy/BriefingV2QueryStrategy.java | 2 -- .../domain/repository/BriefingCustomRepositoryImpl.java | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/briefing/briefing/application/strategy/BriefingV1QueryStrategy.java b/src/main/java/briefing/briefing/application/strategy/BriefingV1QueryStrategy.java index 2bc3ee3..43a5bd0 100644 --- a/src/main/java/briefing/briefing/application/strategy/BriefingV1QueryStrategy.java +++ b/src/main/java/briefing/briefing/application/strategy/BriefingV1QueryStrategy.java @@ -2,7 +2,6 @@ import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.Collections; import java.util.List; import java.util.Optional; @@ -32,7 +31,6 @@ public List findBriefings(BriefingRequestParam.BriefingPreviewListPara if (briefingList.isEmpty()) { briefingList = briefingRepository.findTop10ByTypeOrderByCreatedAtDesc(BriefingType.SOCIAL); - Collections.reverse(briefingList); } return briefingList; } diff --git a/src/main/java/briefing/briefing/application/strategy/BriefingV2QueryStrategy.java b/src/main/java/briefing/briefing/application/strategy/BriefingV2QueryStrategy.java index ce35ca7..3cb28e2 100644 --- a/src/main/java/briefing/briefing/application/strategy/BriefingV2QueryStrategy.java +++ b/src/main/java/briefing/briefing/application/strategy/BriefingV2QueryStrategy.java @@ -2,7 +2,6 @@ import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.Collections; import java.util.List; import java.util.Optional; @@ -34,7 +33,6 @@ public List findBriefings(BriefingRequestParam.BriefingPreviewListPara } briefingList = briefingRepository.findTop10ByTypeOrderByCreatedAtDesc(params.getType()); - Collections.reverse(briefingList); return briefingList; } diff --git a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java b/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java index 8eeefdb..d34a3ba 100644 --- a/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java +++ b/src/main/java/briefing/briefing/domain/repository/BriefingCustomRepositoryImpl.java @@ -78,7 +78,7 @@ public List findTop10ByTypeOrderByCreatedAtDesc(BriefingType type) { .on(scrap.briefing.eq(briefing)) .where(briefing.type.eq(type)) .groupBy(briefing) - .orderBy(date.desc(), briefing.ranks.desc()) + .orderBy(date.desc(), briefing.ranks.asc()) .limit(10) .fetch();