Skip to content

Commit

Permalink
[feat] create dto for ranking api
Browse files Browse the repository at this point in the history
  • Loading branch information
Parkjyun committed Feb 12, 2024
1 parent 8160a64 commit f6c5fcf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.pingle.pingleserver.dto.response;

import java.time.LocalDateTime;

public record RankingIndividualResponse (String name, LocalDateTime latestVisitedDate, Long locationCount) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.pingle.pingleserver.dto.response;

import java.util.List;

public record RankingResponse (int meetingCount, List<RankingIndividualResponse> locations) {
public static RankingResponse of (List<RankingIndividualResponse> responses) {
return new RankingResponse(getSumOfMeetings(responses), responses);
}

private static int getSumOfMeetings (List<RankingIndividualResponse> responses) {
int sum = 0;
for (RankingIndividualResponse response : responses) {
sum += response.locationCount();
}
return sum;
}
}

0 comments on commit f6c5fcf

Please sign in to comment.