Skip to content

Commit 5a49314

Browse files
committed
feat: contribution count 집계 주기를 10분으로 수정한다
1 parent d10f4b6 commit 5a49314

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/main/kotlin/org/gitanimals/render/domain/User.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ class User(
145145
}
146146

147147
@JsonIgnore
148-
fun isContributionUpdatedBeforeOneHour(): Boolean {
148+
fun isContributionUpdatedLongAgo(): Boolean {
149149
val currentYear = instant().toZonedDateTime(ZoneId.of("UTC")).year
150150
val currentYearContribution =
151151
contributions.firstOrNull { it.year == currentYear } ?: return true
152152

153153
return currentYearContribution.lastUpdatedContribution.isBefore(
154-
Instant.now().minus(1, ChronoUnit.HOURS)
154+
Instant.now().minus(10, ChronoUnit.MINUTES)
155155
)
156156
}
157157

src/main/kotlin/org/gitanimals/render/domain/UserService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class UserService(
4545
return increasedContributionCount
4646
}
4747

48-
fun isContributionUpdatedBeforeOneHour(name: String): Boolean =
49-
getUserByName(name).isContributionUpdatedBeforeOneHour()
48+
fun isContributionUpdatedLongAgo(name: String): Boolean =
49+
getUserByName(name).isContributionUpdatedLongAgo()
5050

5151
fun getUserByName(name: String): User = userRepository.findByName(name)
5252
?: throw IllegalArgumentException("Cannot find exists user by name \"$name\"")

src/main/kotlin/org/gitanimals/render/infra/VisitedEventListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class VisitedEventListener(
3535

3636
logger.info("[VisitedEventListener] Increase visit to user. username: \"$username\"")
3737

38-
if (!userService.isContributionUpdatedBeforeOneHour(username)) {
38+
if (userService.isContributionUpdatedLongAgo(username).not()) {
3939
return
4040
}
4141

src/test/kotlin/org/gitanimals/render/domain/UserTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ internal class UserTest(
7474
)
7575

7676
it("true를 반환한다.") {
77-
user.isContributionUpdatedBeforeOneHour() shouldBeEqual true
77+
user.isContributionUpdatedLongAgo() shouldBeEqual true
7878
}
7979
}
8080

8181
context("user의 현재년도에 해당하는 contribution을 찾을 수 없는 경우,") {
8282
val user = user()
8383
it("true를 반환한다.") {
84-
user.isContributionUpdatedBeforeOneHour() shouldBeEqual true
84+
user.isContributionUpdatedLongAgo() shouldBeEqual true
8585
}
8686
}
8787

@@ -96,7 +96,7 @@ internal class UserTest(
9696
)
9797
)
9898
it("false를 반환한다.") {
99-
user.isContributionUpdatedBeforeOneHour() shouldBeEqual false
99+
user.isContributionUpdatedLongAgo() shouldBeEqual false
100100
}
101101
}
102102
}

0 commit comments

Comments
 (0)