mirror of
https://github.com/MewoLab/AquaDX.git
synced 2025-12-14 11:56:15 +08:00
[+] Music popularity api
This commit is contained in:
@@ -6,6 +6,7 @@ import icu.samnyan.aqua.net.components.JWT
|
||||
import icu.samnyan.aqua.sega.allnet.AllNetProps
|
||||
import icu.samnyan.aqua.sega.allnet.KeyChipRepo
|
||||
import icu.samnyan.aqua.sega.allnet.KeychipSession
|
||||
import icu.samnyan.aqua.sega.general.GameMusicPopularity
|
||||
import icu.samnyan.aqua.sega.general.dao.CardRepository
|
||||
import icu.samnyan.aqua.sega.general.model.Card
|
||||
import jakarta.persistence.*
|
||||
@@ -117,7 +118,8 @@ class AquaUserServices(
|
||||
val keyChipRepo: KeyChipRepo,
|
||||
val allNetProps: AllNetProps,
|
||||
val jwt: JWT,
|
||||
val em: EntityManager
|
||||
val em: EntityManager,
|
||||
val pop: GameMusicPopularity
|
||||
) {
|
||||
companion object {
|
||||
val SETTING_FIELDS = AquaUserServices::class.functions
|
||||
|
||||
@@ -226,4 +226,7 @@ abstract class GameApiController<T : IUserData>(val name: String, userDataClass:
|
||||
recommendedMusic = data
|
||||
logger.info("Recommender updated with ${data.size} users")
|
||||
}
|
||||
|
||||
@API("song-pop")
|
||||
fun songPopRanking() = us.pop.ranking[name]
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@ package icu.samnyan.aqua.sega.general
|
||||
|
||||
import ext.*
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import jakarta.persistence.EntityManager
|
||||
import org.springframework.scheduling.annotation.Scheduled
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDate
|
||||
|
||||
@Component
|
||||
class GameMusicPopularity(val us: AquaUserServices) {
|
||||
class GameMusicPopularity(val em: EntityManager) {
|
||||
companion object {
|
||||
val log = logger()
|
||||
|
||||
@@ -23,8 +24,8 @@ class GameMusicPopularity(val us: AquaUserServices) {
|
||||
// Get the play count of each music in the last N days
|
||||
val after = LocalDate.now().minusDays(LOOK_BACK_DAYS).isoDate()
|
||||
|
||||
ranking = ls("chusan", "ongeki").associateWith { game ->
|
||||
us.em.createNativeQuery("""
|
||||
ranking = ls("maimai2", "chusan", "ongeki", "wacca").associateWith { game ->
|
||||
em.createNativeQuery("""
|
||||
SELECT music_id, count(user_id) as count
|
||||
FROM ${game}_user_playlog_view
|
||||
WHERE user_play_date >= '${after}'
|
||||
|
||||
Reference in New Issue
Block a user