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