Skip to content

Commit 2c9e1dc

Browse files
authored
release: 1.2.5 (#135)
2 parents 7aa7f09 + 5d8a988 commit 2c9e1dc

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

docs/api/rank/get_rank.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
### Http method: `GET`
77
### URL: `https://render.gitanimals.org/ranks`
88
### Parameter
9-
- rank: 1 //특정 랭크를 입력하면 해당 랭크부터 {size} 수 만큼 응답합니다.
9+
- rank: 0 //특정 랭크를 입력하면 해당 랭크부터 {size} 수 만큼 응답합니다.
1010
- size: 10 // 조회할 랭크의 수 입니다. default: 10
1111
- type: WEEKLY_GUILD_CONTRIBUTIONS, WEEKLY_USER_CONTRIBUTIONS // 조회할 랭크의 타입을 입력합니다.
1212

@@ -16,12 +16,14 @@
1616
{
1717
"ranks": [
1818
{
19+
"id": "123", // user면 user의 id guild면 guild의 id
1920
"rank": 1,
2021
"image": "https://static.gitanimals.org/...",
2122
"name": "dog",
2223
"contributions": 3,
2324
},
2425
{
26+
"id": "124",
2527
"rank": 2,
2628
"image": "https://static.gitanimals.org/...",
2729
"name": "cat",

docs/api/rank/get_rank_by_username.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
## Response
1010
```json
1111
{
12+
"id": "123", // user면 user의 id guild면 guild의 id
1213
"rank": 100,
1314
"image": "https://static.gitanimals.org/...",
1415
"name": "dog",

src/main/kotlin/org/gitanimals/quiz/domain/context/QuizSolveContextRepository.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ interface QuizSolveContextRepository : JpaRepository<QuizSolveContext, Long> {
1313
solvedAt: LocalDate,
1414
): QuizSolveContext?
1515

16-
@Lock(LockModeType.PESSIMISTIC_WRITE)
1716
@Query("select q from QuizSolveContext q join fetch q.quizSolveContextQuiz where q.id = :id and q.userId = :userId")
1817
fun findByIdAndUserId(
1918
id: Long,
2019
userId: Long,
2120
): QuizSolveContext?
21+
22+
@Lock(LockModeType.PESSIMISTIC_WRITE)
23+
@Query("select q from QuizSolveContext q join fetch q.quizSolveContextQuiz where q.id = :id and q.userId = :userId")
24+
fun findByIdAndUserIdWithLock(
25+
id: Long,
26+
userId: Long,
27+
): QuizSolveContext?
2228
}

src/main/kotlin/org/gitanimals/quiz/domain/context/QuizSolveContextService.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,26 @@ class QuizSolveContextService(
4444

4545
@Transactional
4646
fun solveQuiz(id: Long, userId: Long, answer: String) {
47-
val quizSolveContext = getQuizSolveContextByIdAndUserId(id, userId)
47+
val quizSolveContext = getQuizSolveContextByIdAndUserIdWithLock(id, userId)
4848

4949
quizSolveContext.solve(answer)
5050
}
5151

5252
@Transactional
5353
fun stopQuizByIdAndUserId(id: Long, userId: Long) {
54-
val quizSolveContext = getQuizSolveContextByIdAndUserId(id, userId)
54+
val quizSolveContext = getQuizSolveContextByIdAndUserIdWithLock(id, userId)
5555

5656
quizSolveContext.stopSolve()
5757
}
5858

59+
private fun getQuizSolveContextByIdAndUserIdWithLock(
60+
id: Long,
61+
userId: Long
62+
): QuizSolveContext {
63+
return quizSolveContextRepository.findByIdAndUserIdWithLock(id, userId)
64+
?: throw IllegalArgumentException("Cannot find quizContext by id: \"$id\" and userId: \"$userId\"")
65+
}
66+
5967
fun getQuizSolveContextByIdAndUserId(
6068
id: Long,
6169
userId: Long

0 commit comments

Comments
 (0)