Skip to content

Commit

Permalink
feat: temp deploy version
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Oct 3, 2024
1 parent 49addc2 commit aca443e
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import javax.validation.Valid;

/**
Expand Down Expand Up @@ -48,15 +46,15 @@ public ResponseEntity<Void> updateBlockchain() {

/** 유저들의 개인 랭킹 정보를 조회하기 위한 api */
@GetMapping("/ranking")
public ResponseEntity<List<MemberRankResponse>> getRank(
public ResponseEntity<MemberRankResponses> getRank(
@PageableDefault(sort = "tokens", direction = Sort.Direction.DESC)
final Pageable pageable) {
return ResponseEntity.ok(memberFacade.findMemberRanking(pageable));
}

/** 유저들의 조직에서의 개인 랭킹 정보를 조회하기 위한 api */
@GetMapping("/ranking/organization")
public ResponseEntity<List<MemberRankResponse>> getOrganizationMemberRank(
public ResponseEntity<MemberRankResponses> getOrganizationMemberRank(
@RequestParam Long organizationId,
@PageableDefault(sort = "tokens", direction = Sort.Direction.DESC)
final Pageable pageable) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MemberRankResponse> ranks;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 멤버 정렬 조건을 설정하는 클래스
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

import org.springframework.data.domain.Pageable;

import java.util.List;

@TransactionService
@RequiredArgsConstructor
public class MemberFacade {
Expand All @@ -33,11 +31,11 @@ public void updateBlockchain() {
memberService.updateBlockchain();
}

public List<MemberRankResponse> findMemberRanking(final Pageable pageable) {
public MemberRankResponses findMemberRanking(final Pageable pageable) {
return memberService.findMemberRanking(pageable);
}

public List<MemberRankResponse> findMemberRankingByOrganization(
public MemberRankResponses findMemberRankingByOrganization(
final Long organizationId, final Pageable pageable) {
return memberService.findMemberRankingByOrganization(organizationId, pageable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ private MemberResponse getMemberResponse(final Member member) {
}

@Transactional(readOnly = true)
public List<MemberRankResponse> findMemberRanking(final Pageable pageable) {
return memberRepository.findRanking(pageable);
public MemberRankResponses findMemberRanking(final Pageable pageable) {
final List<MemberRankResponse> ranking = memberRepository.findRanking(pageable);
return new MemberRankResponses(ranking);
}

public void updateWalletAddress(final WalletRequest walletRequest) {
Expand All @@ -134,9 +135,11 @@ private void sendRepositoryRequestToKafka(final String githubId) {
}

@Transactional(readOnly = true)
public List<MemberRankResponse> findMemberRankingByOrganization(
public MemberRankResponses findMemberRankingByOrganization(
final Long organizationId, final Pageable pageable) {
return memberRepository.findRankingByOrganization(organizationId, pageable);
final List<MemberRankResponse> rankingByOrganization =
memberRepository.findRankingByOrganization(organizationId, pageable);
return new MemberRankResponses(rankingByOrganization);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 =
Expand All @@ -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())
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ void getMemberRankingByOrganization() {

// when
List<MemberRankResponse> 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()))
Expand Down

0 comments on commit aca443e

Please sign in to comment.