Reduce logs during statistics import
parent
33e6b23a6b
commit
443bde126f
|
@ -38,26 +38,31 @@ object StatisticsImporter {
|
|||
val statsFile = StatsFile.fromJson(file.readText())
|
||||
val playerId = file.nameWithoutExtension
|
||||
|
||||
val playerStats = emptyMap<String, MutableMap<String, Long>>().toMutableMap()
|
||||
|
||||
transaction(database) {
|
||||
addLogger(StdOutSqlLogger)
|
||||
|
||||
val playerStats = emptyMap<String, MutableMap<String, Long>>().toMutableMap()
|
||||
|
||||
LiveStatistics.slice(LiveStatistics.type, LiveStatistics.name, LiveStatistics.value)
|
||||
.select { LiveStatistics.playerId eq playerId }
|
||||
.forEach {
|
||||
if (playerStats.containsKey(it[LiveStatistics.type])) {
|
||||
playerStats[it[LiveStatistics.type]]?.put(
|
||||
it[LiveStatistics.name], it[LiveStatistics.value])
|
||||
it[LiveStatistics.name],
|
||||
it[LiveStatistics.value]
|
||||
)
|
||||
} else {
|
||||
playerStats.put(
|
||||
it[LiveStatistics.type],
|
||||
mapOf<String, Long>(
|
||||
it[LiveStatistics.name] to
|
||||
it[LiveStatistics.value])
|
||||
.toMutableMap())
|
||||
it[LiveStatistics.value]
|
||||
)
|
||||
.toMutableMap()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
transaction(database) {
|
||||
addLogger(StdOutSqlLogger)
|
||||
|
||||
statsFile?.stats?.forEach { type, stats ->
|
||||
stats.forEach { name, value ->
|
||||
|
@ -113,7 +118,8 @@ object StatisticsImporter {
|
|||
UPDATE SET T."Value" = S."Value", T."Rank" = S."Rank"
|
||||
WHEN NOT MATCHED THEN
|
||||
INSERT VALUES (S."PlayerId", S."Type", S."Name", S."Value", S."Rank")
|
||||
""".trimIndent())
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,9 +182,8 @@ object StatisticsImporter {
|
|||
suspend fun getName(id: String): String? {
|
||||
val response: HttpResponse =
|
||||
httpClient.request(
|
||||
"https://sessionserver.mojang.com/session/minecraft/profile/${id.replace("-", "")}") {
|
||||
method = HttpMethod.Get
|
||||
}
|
||||
"https://sessionserver.mojang.com/session/minecraft/profile/${id.replace("-", "")}"
|
||||
) { method = HttpMethod.Get }
|
||||
if (response.status.isSuccess()) {
|
||||
try {
|
||||
return MojangProfileResponse.fromJson(response.readText())?.name
|
||||
|
|
Loading…
Reference in New Issue