Skip to content

Commit 7faf727

Browse files
authored
release: 1.8.4 (#336)
2 parents 287f6c4 + 65e4fff commit 7faf727

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

src/main/kotlin/org/gitanimals/rank/app/GetRankByUsernameFacade.kt

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class GetRankByUsernameFacade(
2727
)
2828

2929
return RankResponse(
30+
id = userContributionRank.userId.toString(),
3031
rank = rankQueryResponse.rank,
3132
image = userContributionRank.image,
3233
name = userContributionRank.username,

src/main/kotlin/org/gitanimals/rank/app/RankQueryFacade.kt

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ class RankQueryFacade(
2323
size: Int,
2424
type: RankQueryRepository.Type,
2525
): List<RankResponse> {
26-
val rankWithIds =
27-
rankQueryRepository.findAllRank(rankStartedAt = rank, limit = rank + size, type = type)
28-
.associate { it.rank to it.id }
26+
require(size > 1) { "Size must be lager than 1. size: $size" }
27+
require(size <= 20) { "Maximum request size is 20. size: $size" }
28+
require(rank > 0) { "Rank must be larger than 0. rank: $rank" }
29+
30+
val rankWithIds = rankQueryRepository.findAllRank(
31+
rankStartedAt = rank,
32+
limit = rank + size - 1,
33+
type = type
34+
).associate { it.rank to it.id }
2935

3036
return when (type) {
3137
WEEKLY_GUILD_CONTRIBUTIONS -> guildContributionRankService.findAllByRankIds(rankWithIds)

src/main/kotlin/org/gitanimals/rank/domain/GuildContributionRankService.kt

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class GuildContributionRankService(
3939

4040
return guildContributionRankRepository.findAllById(rankIds).map {
4141
RankResponse(
42+
id = it.guildId.toString(),
4243
rank = idWithRank[it.id]
4344
?: throw IllegalStateException("Cannot find rank value by id ${it.id}"),
4445
image = it.image,

src/main/kotlin/org/gitanimals/rank/domain/UserContributionRankService.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class UserContributionRankService(
2020
val userRank = runCatching {
2121
userContributionRankRepository.findByUserId(updateUserContributionRank.userId)?.also {
2222
it.weeklyContributions += updateUserContributionRank.weeklyContributions
23-
} ?: throw IllegalArgumentException("Cannot find UserContributionRank by userId: \"${updateUserContributionRank.userId}\"")
23+
}
24+
?: throw IllegalArgumentException("Cannot find UserContributionRank by userId: \"${updateUserContributionRank.userId}\"")
2425
}.getOrElse {
2526
userContributionRankRepository.save(updateUserContributionRank)
2627
}
@@ -41,6 +42,7 @@ class UserContributionRankService(
4142

4243
return userContributionRankRepository.findAllById(rankIds).map {
4344
RankResponse(
45+
id = it.userId.toString(),
4446
rank = idWithRank[it.id]
4547
?: throw IllegalStateException("Cannot find rank value by id ${it.id}"),
4648
image = it.image,

src/main/kotlin/org/gitanimals/rank/domain/response/RankResponse.kt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.gitanimals.rank.domain.response
22

33
data class RankResponse(
4+
val id: String,
45
val rank: Int,
56
val image: String,
67
val name: String,

0 commit comments

Comments
 (0)