Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.springframework.beans.factory.annotation.Autowired
- import org.springframework.stereotype.Component
- import pl.cyganki.results.repository.ResultRepository
- @Component
- class Greeter
- {
- @Autowired
- lateinit var resultRepository:ResultRepository
- fun getTaskUserDetails(tournamentId: String, taskId: String, userId: Long) =
- with(resultRepository.findAllByTournamentIdAndTaskIdAndUserId(tournamentId, taskId, userId)) {
- pl.cyganki.utils.model.TaskUserDetails(
- taskId,
- if (isNotEmpty()) maxBy { it.earnedPoints }!!.earnedPoints else 0,
- size
- )
- }
- fun getAllTasksUserDetailsInTournament(tournamentId: String, taskIds: List<String>, userId: Long) =
- taskIds
- .map { it to this.getTaskUserDetails(tournamentId, it, userId) }
- .toMap()
- }
- fun main(args : Array<String>) {
- val taskids = listOf("000000000000000000000094")
- Greeter().getAllTasksUserDetailsInTournament("000000000000000000000011", taskids, 7)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement