Skip to content

Commit 9ce25a5

Browse files
authored
release: 0.9.8 (#215)
2 parents 705f52f + fdc26f6 commit 9ce25a5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

โ€Žsrc/main/kotlin/org/gitanimals/render/controller/PersonaController.ktโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class PersonaController(
2525

2626
@GetMapping("/users/{username}")
2727
fun getUserByName(@PathVariable("username") username: String): UserResponse {
28-
return UserResponse.from(userService.getUserByName(username))
28+
return UserResponse.from(userService.getUserByNameWithAllContributions(username))
2929
}
3030

3131
@GetMapping("/personas/{persona-id}")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
package org.gitanimals.render.domain
22

33
import org.springframework.data.jpa.repository.JpaRepository
4+
import org.springframework.data.jpa.repository.Query
5+
import org.springframework.data.repository.query.Param
46

57
interface UserRepository : JpaRepository<User, Long> {
68

79
fun findByName(name: String): User?
810

11+
@Query(
12+
"""
13+
select u from User as u
14+
left join fetch u.contributions
15+
where u.name = :name
16+
"""
17+
)
18+
fun findByNameWithContributions(@Param("name") name: String): User?
19+
920
fun existsByName(name: String): Boolean
1021
}

โ€Žsrc/main/kotlin/org/gitanimals/render/domain/UserService.ktโ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class UserService(
4848
fun getUserByName(name: String): User = userRepository.findByName(name)
4949
?: throw IllegalArgumentException("Cannot find exists user by name \"$name\"")
5050

51+
fun getUserByNameWithAllContributions(name: String): User = userRepository.findByName(name)
52+
?: throw IllegalArgumentException("Cannot find exists user by name \"$name\"")
53+
5154
@Transactional
5255
fun createNewUser(name: String, contributions: Map<Int, Int>): User =
5356
userRepository.save(User.newUser(name, contributions))

0 commit comments

Comments
ย (0)