[F] Fix apis

pull/14/head
Azalea 2024-02-26 23:19:10 -05:00
parent f086b8abe9
commit b44121597f
6 changed files with 18 additions and 33 deletions

View File

@ -12,7 +12,6 @@ import icu.samnyan.aqua.sega.chusan.dao.userdata.UserDataRepository
import icu.samnyan.aqua.sega.chusan.dao.userdata.UserGeneralDataRepository
import icu.samnyan.aqua.sega.chusan.dao.userdata.UserPlaylogRepository
import org.springframework.web.bind.annotation.RestController
import java.time.format.DateTimeFormatter
@RestController
@API("api/v2/game/chu3")
@ -24,9 +23,8 @@ class Chusan(
): GameApiController
{
override fun trend(@RP username: Str): List<TrendOut> = us.byName(username) { u ->
val fmt = DateTimeFormatter.ofPattern("YYYY-MM-DD")
findTrend(userPlaylogRepository.findByUser_Card_ExtId(u.ghostCard.extId)
.map { TrendLog(fmt.format(it.playDate), it.playerRating) })
.map { TrendLog(it.playDate.toString(), it.playerRating) })
}
// Only show > AAA rank

View File

@ -2,17 +2,10 @@ package icu.samnyan.aqua.net.games
import ext.API
import ext.RP
import icu.samnyan.aqua.net.utils.IGenericGamePlaylog
data class TrendOut(val date: String, val rating: Int, val plays: Int)
data class GenericGamePlaylog(
val playDate: String,
val achievement: Int,
val maxCombo: Int,
val totalCombo: Int,
val afterRating: Int
)
data class RankCount(val name: String, val count: Int)
data class GenericGameSummary(
@ -37,7 +30,7 @@ data class GenericGameSummary(
val ratingComposition: Map<String, Any>,
val recent: List<GenericGamePlaylog>
val recent: List<IGenericGamePlaylog>
)
interface GameApiController {

View File

@ -2,7 +2,6 @@ package icu.samnyan.aqua.net.utils
import ext.minus
import icu.samnyan.aqua.net.db.AquaNetUser
import icu.samnyan.aqua.net.games.GenericGamePlaylog
import icu.samnyan.aqua.net.games.GenericGameSummary
import icu.samnyan.aqua.net.games.RankCount
import icu.samnyan.aqua.net.games.TrendOut
@ -48,10 +47,13 @@ interface GenericUserDataRepo {
}
interface IGenericGamePlaylog {
val musicId: Int
val level: Int
val date: Any
val achievement: Int
val maxCombo: Int
val totalCombo: Int
val beforeRating: Int
val afterRating: Int
}
@ -96,9 +98,7 @@ fun genericUserSummary(
lastSeen = user.lastPlayDate.toString(),
lastVersion = user.lastRomVersion,
ratingComposition = ratingComposition,
recent = plays.sortedBy { it.date.toString() }.takeLast(15).map {
GenericGamePlaylog(it.date.toString(), it.achievement, it.maxCombo, it.totalCombo, it.afterRating)
}
recent = plays.sortedBy { it.date.toString() }.takeLast(15)
)
}

View File

@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author samnyan (privateamusement@protonmail.com)
@ -171,4 +172,9 @@ public class UserPlaylog implements Serializable, IGenericGamePlaylog {
public String getDate() {
return playDate.toString();
}
@Override
public int getBeforeRating() {
return playerRating; // TODO: Get before rating
}
}

View File

@ -180,4 +180,9 @@ public class UserPlaylog implements Serializable, IGenericGamePlaylog {
public int getAfterRating() {
return playerRating;
}
@Override
public int getBeforeRating() {
return playerRating; // TODO: Get before rating
}
}

View File

@ -1,17 +0,0 @@
-- maimai2_user_playlog
-- Set ext_bool1 as NOT NULL and give it a default value (e.g., FALSE)
UPDATE maimai2_user_playlog SET ext_bool1 = FALSE WHERE ext_bool1 IS NULL;
ALTER TABLE maimai2_user_playlog MODIFY COLUMN ext_bool1 BOOLEAN NOT NULL DEFAULT FALSE;
-- Set ext_num4 as NOT NULL (assuming it already has a default value of 0)
UPDATE maimai2_user_playlog SET ext_num4 = 0 WHERE ext_num4 IS NULL;
ALTER TABLE maimai2_user_playlog MODIFY COLUMN ext_num4 INTEGER NOT NULL DEFAULT 0;
-- maimai2_user_detail
-- Add default value for current_play_count and set it as NOT NULL
UPDATE maimai2_user_detail SET current_play_count = 0 WHERE current_play_count IS NULL;
ALTER TABLE maimai2_user_detail MODIFY COLUMN current_play_count INTEGER NOT NULL DEFAULT 0;
-- Add default value for rename_credit and set it as NOT NULL
UPDATE maimai2_user_detail SET rename_credit = 0 WHERE rename_credit IS NULL;
ALTER TABLE maimai2_user_detail MODIFY COLUMN rename_credit INTEGER NOT NULL DEFAULT 0;