diff --git a/build.gradle b/build.gradle index c045d79..f25426e 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,7 @@ dependencies { implementation group: "org.springframework.boot", name: "spring-boot-starter-security", version: "2.3.3.RELEASE" implementation group: "org.springframework.boot", name: "spring-boot-starter-data-r2dbc", version: "2.3.3.RELEASE" annotationProcessor group: "org.springframework.boot", name: "spring-boot-configuration-processor", version: "2.3.3.RELEASE" + developmentOnly group: "org.springframework.boot", name: "spring-boot-devtools", version: "2.3.3.RELEASE" implementation group: "org.flywaydb", name: "flyway-core", version: "6.5.2" implementation group: "io.r2dbc", name: "r2dbc-postgresql", version: "0.8.4.RELEASE" diff --git a/src/main/kotlin/me/honnold/ladderhero/dao/domain/Summary.kt b/src/main/kotlin/me/honnold/ladderhero/dao/domain/Summary.kt index 489f5da..e111ab9 100644 --- a/src/main/kotlin/me/honnold/ladderhero/dao/domain/Summary.kt +++ b/src/main/kotlin/me/honnold/ladderhero/dao/domain/Summary.kt @@ -22,6 +22,8 @@ data class Summary( var name: String, @Column("did_win") var didWin: Boolean, + @Column("mmr") + var mmr: Long = 0, @Column("collected_minerals") var collectedMinerals: Long = 0, @Column("collected_vespene") diff --git a/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplayDetailRow.kt b/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplayDetailRow.kt index 14cf350..d1ec053 100644 --- a/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplayDetailRow.kt +++ b/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplayDetailRow.kt @@ -29,6 +29,8 @@ data class ReplayDetailRow( var teamId: Long, @Column("did_win") var didWin: Boolean, + @Column("mmr") + var mmr: Long, @Column("profile_id") var profileId: Long, @Column("region_id") diff --git a/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplaySummaryRow.kt b/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplaySummaryRow.kt index 8f98ef1..60c50be 100644 --- a/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplaySummaryRow.kt +++ b/src/main/kotlin/me/honnold/ladderhero/dao/value/ReplaySummaryRow.kt @@ -26,6 +26,8 @@ data class ReplaySummaryRow( var teamId: Long, @Column("did_win") var didWin: Boolean, + @Column("mmr") + var mmr: Long, @Column("profile_id") var profileId: Long, @Column("region_id") diff --git a/src/main/kotlin/me/honnold/ladderhero/service/AuthService.kt b/src/main/kotlin/me/honnold/ladderhero/service/AuthService.kt index 284e169..5e1fd7a 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/AuthService.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/AuthService.kt @@ -5,7 +5,6 @@ import me.honnold.ladderhero.service.domain.UserService import me.honnold.ladderhero.service.dto.AuthedUser import me.honnold.ladderhero.service.dto.JWTToken import me.honnold.ladderhero.web.request.AuthRequest -import org.slf4j.LoggerFactory import org.springframework.dao.DataIntegrityViolationException import org.springframework.security.authentication.BadCredentialsException import org.springframework.security.core.userdetails.UsernameNotFoundException @@ -21,10 +20,6 @@ class AuthService( private val jwtService: JWTService, private val blizzardService: BlizzardService ) { - companion object { - private val logger = LoggerFactory.getLogger(AuthService::class.java) - } - fun getMe(username: String): Mono { val authedUser = AuthedUser(username) diff --git a/src/main/kotlin/me/honnold/ladderhero/service/UploadService.kt b/src/main/kotlin/me/honnold/ladderhero/service/UploadService.kt index a4bc5e8..4bda906 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/UploadService.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/UploadService.kt @@ -2,7 +2,6 @@ package me.honnold.ladderhero.service import me.honnold.ladderhero.service.domain.FileService import me.honnold.ladderhero.service.dto.upload.UploadResult -import org.slf4j.LoggerFactory import org.springframework.http.codec.multipart.FilePart import org.springframework.stereotype.Service import reactor.core.publisher.Flux @@ -13,10 +12,6 @@ class UploadService( private val fileService: FileService, private val replayProcessingService: ReplayProcessingService ) { - companion object { - private val logger = LoggerFactory.getLogger(UploadService::class.java) - } - fun uploadFiles(files: Flux): Flux { return files .flatMap { part -> this.s3ClientService.upload(part) } diff --git a/src/main/kotlin/me/honnold/ladderhero/service/domain/FileService.kt b/src/main/kotlin/me/honnold/ladderhero/service/domain/FileService.kt index fc60261..2ff8928 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/domain/FileService.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/domain/FileService.kt @@ -3,16 +3,11 @@ package me.honnold.ladderhero.service.domain import me.honnold.ladderhero.dao.FileUploadDAO import me.honnold.ladderhero.dao.domain.FileUpload import me.honnold.ladderhero.service.dto.upload.UploadResult -import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import reactor.core.publisher.Mono @Service class FileService(private val fileUploadDAO: FileUploadDAO) { - companion object { - private val logger = LoggerFactory.getLogger(FileService::class.java) - } - fun saveUploadResult(result: UploadResult): Mono { val fileUpload = FileUpload(key = result.fileKey, fileName = result.fileName) diff --git a/src/main/kotlin/me/honnold/ladderhero/service/domain/ReplayService.kt b/src/main/kotlin/me/honnold/ladderhero/service/domain/ReplayService.kt index 94fcedc..36239a5 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/domain/ReplayService.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/domain/ReplayService.kt @@ -54,7 +54,8 @@ class ReplayService(private val replayDAO: ReplayDAO) { player.name, player.profileId, player.teamId, - player.didWin + player.didWin, + player.mmr ) } ) @@ -91,6 +92,7 @@ class ReplayService(private val replayDAO: ReplayDAO) { playerSnapshots[0].name, playerSnapshots[0].teamId, playerSnapshots[0].didWin, + playerSnapshots[0].mmr, playerSnapshots[0].profileId, playerSnapshots[0].totalLostMinerals, playerSnapshots[0].totalLostVespene, diff --git a/src/main/kotlin/me/honnold/ladderhero/service/domain/SummaryService.kt b/src/main/kotlin/me/honnold/ladderhero/service/domain/SummaryService.kt index e1bdf78..1d27d33 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/domain/SummaryService.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/domain/SummaryService.kt @@ -54,8 +54,9 @@ class SummaryService( val jsonPlayer = data.metadata.players.find { p -> p.playerId == workingId } val didWin = jsonPlayer?.result == "Win" + val mmr = jsonPlayer?.mmr ?: 0 - val summary = Summary(null, replay.id, player.id, workingId, teamId, race, name, didWin) + val summary = Summary(null, replay.id, player.id, workingId, teamId, race, name, didWin, mmr) return this.summaryDAO.save(summary) } diff --git a/src/main/kotlin/me/honnold/ladderhero/service/domain/UserService.kt b/src/main/kotlin/me/honnold/ladderhero/service/domain/UserService.kt index c30138e..295cf02 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/domain/UserService.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/domain/UserService.kt @@ -2,16 +2,11 @@ package me.honnold.ladderhero.service.domain import me.honnold.ladderhero.dao.UserDAO import me.honnold.ladderhero.dao.domain.User -import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import reactor.core.publisher.Mono @Service class UserService(private val userDAO: UserDAO) { - companion object { - private val logger = LoggerFactory.getLogger(UserService::class.java) - } - fun getUser(username: String): Mono { return this.userDAO.findByUsername(username) } diff --git a/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplayDetails.kt b/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplayDetails.kt index 102127d..cb61051 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplayDetails.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplayDetails.kt @@ -20,6 +20,7 @@ data class ReplayDetails( val name: String = "", val teamId: Long = 0, val didWin: Boolean = false, + var mmr: Long = 0, val profileId: Long = 0, val totalLostMinerals: Long = 0, val totalLostVespene: Long = 0, diff --git a/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplaySummary.kt b/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplaySummary.kt index 497dab2..2a98ec6 100644 --- a/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplaySummary.kt +++ b/src/main/kotlin/me/honnold/ladderhero/service/dto/replay/ReplaySummary.kt @@ -18,6 +18,7 @@ data class ReplaySummary( val name: String, val profileId: Long, val teamId: Long, - var didWin: Boolean + var didWin: Boolean, + var mmr: Long ) } diff --git a/src/main/kotlin/me/honnold/ladderhero/web/BlizzardController.kt b/src/main/kotlin/me/honnold/ladderhero/web/BlizzardController.kt index d9bd4d7..6a0456e 100644 --- a/src/main/kotlin/me/honnold/ladderhero/web/BlizzardController.kt +++ b/src/main/kotlin/me/honnold/ladderhero/web/BlizzardController.kt @@ -2,7 +2,6 @@ package me.honnold.ladderhero.web import me.honnold.ladderhero.service.BlizzardService import me.honnold.ladderhero.util.toUUID -import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Qualifier import org.springframework.http.HttpStatus import org.springframework.http.server.reactive.ServerHttpResponse @@ -21,10 +20,6 @@ class BlizzardController( @Qualifier("homePageUri") private val homePageUri: URI ) { - companion object { - private val logger = LoggerFactory.getLogger(BlizzardController::class.java) - } - @GetMapping(path = ["/authorize"]) fun authorizeBlizzard(principal: Principal, response: ServerHttpResponse): Mono { return blizzardService.getAuthorizeRedirectUri(principal.name).flatMap { uri -> diff --git a/src/main/kotlin/me/honnold/ladderhero/web/api/v1/ReplayController.kt b/src/main/kotlin/me/honnold/ladderhero/web/api/v1/ReplayController.kt index ac15bc8..4b4e989 100644 --- a/src/main/kotlin/me/honnold/ladderhero/web/api/v1/ReplayController.kt +++ b/src/main/kotlin/me/honnold/ladderhero/web/api/v1/ReplayController.kt @@ -3,7 +3,6 @@ package me.honnold.ladderhero.web.api.v1 import me.honnold.ladderhero.service.domain.ReplayService import me.honnold.ladderhero.service.dto.replay.ReplayDetails import me.honnold.ladderhero.service.dto.replay.ReplaySummary -import org.slf4j.LoggerFactory import org.springframework.data.domain.PageRequest import org.springframework.web.bind.annotation.* import reactor.core.publisher.Flux @@ -12,10 +11,6 @@ import reactor.core.publisher.Mono @RestController @RequestMapping("/api/v1/replays") class ReplayController(private val replayService: ReplayService) { - companion object { - private val logger = LoggerFactory.getLogger(ReplayController::class.java) - } - @GetMapping fun getReplays( @RequestParam(defaultValue = "25") diff --git a/src/main/kotlin/me/honnold/mpq/Archive.kt b/src/main/kotlin/me/honnold/mpq/Archive.kt index 2e4adc6..0dc556e 100644 --- a/src/main/kotlin/me/honnold/mpq/Archive.kt +++ b/src/main/kotlin/me/honnold/mpq/Archive.kt @@ -10,7 +10,6 @@ import java.nio.ByteOrder import java.nio.channels.SeekableByteChannel import java.nio.charset.StandardCharsets import java.nio.file.Path -import java.util.* import kotlin.math.ceil class Archive(path: Path) : AutoCloseable { diff --git a/src/main/resources/db/migration/V1.16__alter_table_summary_add_mmr.sql b/src/main/resources/db/migration/V1.16__alter_table_summary_add_mmr.sql new file mode 100644 index 0000000..559f8bc --- /dev/null +++ b/src/main/resources/db/migration/V1.16__alter_table_summary_add_mmr.sql @@ -0,0 +1,3 @@ +ALTER TABLE public.summary ADD mmr int NULL; +UPDATE public.summary SET mmr = 0 WHERE mmr IS NULL; +ALTER TABLE public.summary ALTER COLUMN mmr SET NOT NULL;