mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-05 09:07:26 +08:00
[O] Move const out, remove unused, fix typo
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package icu.samnyan.aqua.sega.maimai2.handler
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import ext.logger
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import icu.samnyan.aqua.sega.maimai2.model.userdata.QMai2UserPlaylog
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.scheduling.annotation.Scheduled
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDateTime
|
||||
@@ -17,7 +15,6 @@ import kotlin.concurrent.Volatile
|
||||
*/
|
||||
@Component("Maimai2GetGameRankingHandler")
|
||||
class GetGameRankingHandler(
|
||||
private val repos: Mai2Repos,
|
||||
private val queryFactory: JPAQueryFactory
|
||||
) : BaseHandler {
|
||||
private data class MusicRankingItem(val musicId: Int, val weight: Long)
|
||||
@@ -33,9 +30,6 @@ class GetGameRankingHandler(
|
||||
|
||||
@Scheduled(fixedDelay = 3600_000)
|
||||
private fun refreshMusicRankingCache() {
|
||||
val LOOK_BACK_DAYS: Long = 7
|
||||
val QUREY_LIMIT: Long = 50
|
||||
|
||||
// Get the play count of each music in the last N days
|
||||
val queryAfter = LocalDateTime.now().minusDays(LOOK_BACK_DAYS)
|
||||
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
@@ -50,12 +44,11 @@ class GetGameRankingHandler(
|
||||
.where(qPlaylog.userPlayDate.stringValue().goe(queryAfterStr))
|
||||
.groupBy(cMusicId)
|
||||
.orderBy(cUserCount.desc())
|
||||
.limit(QUREY_LIMIT)
|
||||
.limit(QUERY_LIMIT)
|
||||
.fetch()
|
||||
.map { MusicRankingItem(it.get(cMusicId)!!, it.get(cUserCount)!!) }
|
||||
.toList()
|
||||
|
||||
logger.info("Refreshed music ranking cache: ${musicRankingCache.size} items")
|
||||
log.info("Refreshed music ranking cache: ${musicRankingCache.size} items")
|
||||
}
|
||||
|
||||
override fun handle(request: Map<String, Any>): Any = mapOf(
|
||||
@@ -67,6 +60,9 @@ class GetGameRankingHandler(
|
||||
)
|
||||
|
||||
companion object {
|
||||
val logger: Logger = LoggerFactory.getLogger(GetGameRankingHandler::class.java)
|
||||
val log = logger()
|
||||
|
||||
const val LOOK_BACK_DAYS: Long = 7
|
||||
const val QUERY_LIMIT: Long = 50
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user