From aca443e62f6b950e26db4976bbdd3d7dbaa528cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Thu, 3 Oct 2024 18:15:06 +0900 Subject: [PATCH] feat: temp deploy version --- .../domain/member/controller/MemberController.java | 6 ++---- .../member/dto/response/MemberRankResponses.java | 14 ++++++++++++++ .../member/repository/MemberOrderConverter.java | 13 ++++++++++--- .../domain/member/service/MemberFacade.java | 6 ++---- .../domain/member/service/MemberService.java | 11 +++++++---- .../member/controller/MemberControllerTest.java | 8 ++++---- .../domain/member/service/MemberServiceTest.java | 4 +++- 7 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 backend/src/main/java/com/dragonguard/backend/domain/member/dto/response/MemberRankResponses.java diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/controller/MemberController.java b/backend/src/main/java/com/dragonguard/backend/domain/member/controller/MemberController.java index c7f05e0b..3d01fa62 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/controller/MemberController.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/controller/MemberController.java @@ -12,8 +12,6 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import java.util.List; - import javax.validation.Valid; /** @@ -48,7 +46,7 @@ public ResponseEntity updateBlockchain() { /** 유저들의 개인 랭킹 정보를 조회하기 위한 api */ @GetMapping("/ranking") - public ResponseEntity> getRank( + public ResponseEntity getRank( @PageableDefault(sort = "tokens", direction = Sort.Direction.DESC) final Pageable pageable) { return ResponseEntity.ok(memberFacade.findMemberRanking(pageable)); @@ -56,7 +54,7 @@ public ResponseEntity> getRank( /** 유저들의 조직에서의 개인 랭킹 정보를 조회하기 위한 api */ @GetMapping("/ranking/organization") - public ResponseEntity> getOrganizationMemberRank( + public ResponseEntity getOrganizationMemberRank( @RequestParam Long organizationId, @PageableDefault(sort = "tokens", direction = Sort.Direction.DESC) final Pageable pageable) { diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/dto/response/MemberRankResponses.java b/backend/src/main/java/com/dragonguard/backend/domain/member/dto/response/MemberRankResponses.java new file mode 100644 index 00000000..021527ce --- /dev/null +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/dto/response/MemberRankResponses.java @@ -0,0 +1,14 @@ +package com.dragonguard.backend.domain.member.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class MemberRankResponses { + private List ranks; +} diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/repository/MemberOrderConverter.java b/backend/src/main/java/com/dragonguard/backend/domain/member/repository/MemberOrderConverter.java index e6b6bbb2..720fd40c 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/repository/MemberOrderConverter.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/repository/MemberOrderConverter.java @@ -5,11 +5,13 @@ import com.dragonguard.backend.global.template.converter.OrderConverter; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.ComparableExpressionBase; -import java.util.HashMap; -import java.util.Map; + import org.springframework.data.domain.Sort; import org.springframework.stereotype.Component; +import java.util.HashMap; +import java.util.Map; + /** * @author 김승진 * @description 멤버 정렬 조건을 설정하는 클래스 @@ -25,7 +27,12 @@ public MemberOrderConverter() { private void initializeMap() { keywordMap.put("commits", member.sumOfCommits); - keywordMap.put("tokens", member.sumOfTokens); + keywordMap.put( + "tokens", + member.sumOfCommits + .add(member.sumOfCodeReviews) + .add(member.sumOfIssues) + .add(member.sumOfPullRequests)); } @Override diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java index 1f0a3e5d..266d42bb 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberFacade.java @@ -11,8 +11,6 @@ import org.springframework.data.domain.Pageable; -import java.util.List; - @TransactionService @RequiredArgsConstructor public class MemberFacade { @@ -33,11 +31,11 @@ public void updateBlockchain() { memberService.updateBlockchain(); } - public List findMemberRanking(final Pageable pageable) { + public MemberRankResponses findMemberRanking(final Pageable pageable) { return memberService.findMemberRanking(pageable); } - public List findMemberRankingByOrganization( + public MemberRankResponses findMemberRankingByOrganization( final Long organizationId, final Pageable pageable) { return memberService.findMemberRankingByOrganization(organizationId, pageable); } diff --git a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java index cb29fc2e..a85b5cbe 100644 --- a/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java +++ b/backend/src/main/java/com/dragonguard/backend/domain/member/service/MemberService.java @@ -108,8 +108,9 @@ private MemberResponse getMemberResponse(final Member member) { } @Transactional(readOnly = true) - public List findMemberRanking(final Pageable pageable) { - return memberRepository.findRanking(pageable); + public MemberRankResponses findMemberRanking(final Pageable pageable) { + final List ranking = memberRepository.findRanking(pageable); + return new MemberRankResponses(ranking); } public void updateWalletAddress(final WalletRequest walletRequest) { @@ -134,9 +135,11 @@ private void sendRepositoryRequestToKafka(final String githubId) { } @Transactional(readOnly = true) - public List findMemberRankingByOrganization( + public MemberRankResponses findMemberRankingByOrganization( final Long organizationId, final Pageable pageable) { - return memberRepository.findRankingByOrganization(organizationId, pageable); + final List rankingByOrganization = + memberRepository.findRankingByOrganization(organizationId, pageable); + return new MemberRankResponses(rankingByOrganization); } @Override diff --git a/backend/src/test/java/com/dragonguard/backend/domain/member/controller/MemberControllerTest.java b/backend/src/test/java/com/dragonguard/backend/domain/member/controller/MemberControllerTest.java index bb063909..ce166192 100644 --- a/backend/src/test/java/com/dragonguard/backend/domain/member/controller/MemberControllerTest.java +++ b/backend/src/test/java/com/dragonguard/backend/domain/member/controller/MemberControllerTest.java @@ -10,7 +10,6 @@ import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.dragonguard.backend.domain.member.dto.request.WalletRequest; @@ -196,7 +195,7 @@ void getRanking() throws Exception { 500L, Tier.GOLD, "http://github123123412412412profileUrl")); - given(memberFacade.findMemberRanking(any())).willReturn(expected); + given(memberFacade.findMemberRanking(any())).willReturn(new MemberRankResponses(expected)); // when ResultActions perform = @@ -206,7 +205,7 @@ void getRanking() throws Exception { .header("Authorization", "Bearer apfawfawfa.awfsfawef2.r4svfv32")); // then - perform.andExpect(status().isOk()).andExpect(jsonPath("$").isArray()); + perform.andExpect(status().isOk()); // docs perform.andDo(print()) @@ -312,7 +311,8 @@ void getOrganizationMemberRank() throws Exception { 20L, Tier.SPROUT, "http://githubUserProfileImageUrl")); - given(memberFacade.findMemberRankingByOrganization(any(), any())).willReturn(expected); + given(memberFacade.findMemberRankingByOrganization(any(), any())) + .willReturn(new MemberRankResponses(expected)); // when ResultActions perform = diff --git a/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java b/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java index 0a430795..a1f6da58 100644 --- a/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java +++ b/backend/src/test/java/com/dragonguard/backend/domain/member/service/MemberServiceTest.java @@ -170,7 +170,9 @@ void getMemberRankingByOrganization() { // when List response = - memberService.findMemberRankingByOrganization(org.getId(), PageRequest.of(0, 4)); + memberService + .findMemberRankingByOrganization(org.getId(), PageRequest.of(0, 4)) + .getRanks(); // then assertThat(response.stream().map(MemberRankResponse::getId).collect(Collectors.toList()))