Added user search, improved api docs, improved replay compression by 20-25%, user-details allows userId and username
This commit is contained in:
parent
ebaf4c82c5
commit
6ebddca877
@ -9,6 +9,7 @@ import com.nisemoe.nise.osu.Mod
|
|||||||
import com.nisemoe.nise.osu.OsuApi
|
import com.nisemoe.nise.osu.OsuApi
|
||||||
import com.nisemoe.nise.service.AuthService
|
import com.nisemoe.nise.service.AuthService
|
||||||
import com.nisemoe.nise.service.CompressReplay
|
import com.nisemoe.nise.service.CompressReplay
|
||||||
|
import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream
|
||||||
import org.jooq.Condition
|
import org.jooq.Condition
|
||||||
import org.jooq.DSLContext
|
import org.jooq.DSLContext
|
||||||
import org.jooq.Record
|
import org.jooq.Record
|
||||||
@ -19,6 +20,7 @@ import org.nisemoe.mari.judgements.Judgement
|
|||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
import java.util.*
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -64,6 +66,11 @@ class ScoreService(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun decompressData(replayString: String): ByteArray =
|
||||||
|
Base64.getDecoder().decode(replayString).inputStream().use { byteStream ->
|
||||||
|
LZMACompressorInputStream(byteStream).readBytes()
|
||||||
|
}
|
||||||
|
|
||||||
fun getReplayViewerData(replayId: Long): ReplayViewerData? {
|
fun getReplayViewerData(replayId: Long): ReplayViewerData? {
|
||||||
val beatmapId = dslContext.select(SCORES.BEATMAP_ID)
|
val beatmapId = dslContext.select(SCORES.BEATMAP_ID)
|
||||||
.from(SCORES)
|
.from(SCORES)
|
||||||
@ -83,6 +90,7 @@ class ScoreService(
|
|||||||
val replayData = result.get(SCORES.REPLAY, ByteArray::class.java) ?: return null
|
val replayData = result.get(SCORES.REPLAY, ByteArray::class.java) ?: return null
|
||||||
|
|
||||||
val replay = CompressReplay.decompressReplayToString(replayData)
|
val replay = CompressReplay.decompressReplayToString(replayData)
|
||||||
|
val replayDecoded = decompressData(replay)
|
||||||
|
|
||||||
var beatmapFile = result.get(BEATMAPS.BEATMAP_FILE, String::class.java)
|
var beatmapFile = result.get(BEATMAPS.BEATMAP_FILE, String::class.java)
|
||||||
if(beatmapFile == null) {
|
if(beatmapFile == null) {
|
||||||
@ -103,7 +111,7 @@ class ScoreService(
|
|||||||
|
|
||||||
return ReplayViewerData(
|
return ReplayViewerData(
|
||||||
beatmap = beatmapFile,
|
beatmap = beatmapFile,
|
||||||
replay = replay,
|
replay = String(replayDecoded, Charsets.UTF_8).trimEnd(','),
|
||||||
judgements = getJudgements(replayId),
|
judgements = getJudgements(replayId),
|
||||||
mods = mods
|
mods = mods
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user