Fixed batch user statistics, only update replay pairs if new scores have been added to the beatmap
This commit is contained in:
parent
14a2608f2a
commit
051b6384fb
@ -77,27 +77,29 @@ class UserService(
|
||||
fun insertApiUser(apiUser: OsuApiModels.UserExtended) {
|
||||
this.logger.debug("Saving user ${apiUser.username}")
|
||||
|
||||
val userStatistics = apiUser.getStatistics()
|
||||
|
||||
if(dslContext.fetchExists(USERS, USERS.USER_ID.eq(apiUser.id))) {
|
||||
|
||||
dslContext.update(USERS)
|
||||
.set(USERS.USERNAME, apiUser.username)
|
||||
.set(USERS.RANK, apiUser.statistics?.global_rank)
|
||||
.set(USERS.PP_RAW, apiUser.statistics?.pp)
|
||||
.set(USERS.ACCURACY, apiUser.statistics?.hit_accuracy)
|
||||
.set(USERS.TOTAL_SCORE, apiUser.statistics?.total_score)
|
||||
.set(USERS.RANKED_SCORE, apiUser.statistics?.ranked_score)
|
||||
.set(USERS.COUNT_300, apiUser.statistics?.count_300)
|
||||
.set(USERS.COUNT_100, apiUser.statistics?.count_100)
|
||||
.set(USERS.COUNT_50, apiUser.statistics?.count_50)
|
||||
.set(USERS.RANK, userStatistics?.global_rank)
|
||||
.set(USERS.PP_RAW, userStatistics?.pp)
|
||||
.set(USERS.ACCURACY, userStatistics?.hit_accuracy)
|
||||
.set(USERS.TOTAL_SCORE, userStatistics?.total_score)
|
||||
.set(USERS.RANKED_SCORE, userStatistics?.ranked_score)
|
||||
.set(USERS.COUNT_300, userStatistics?.count_300)
|
||||
.set(USERS.COUNT_100, userStatistics?.count_100)
|
||||
.set(USERS.COUNT_50, userStatistics?.count_50)
|
||||
.apply {
|
||||
if(apiUser.join_date != null) {
|
||||
set(USERS.JOIN_DATE, OffsetDateTime.parse(apiUser.join_date).toLocalDateTime())
|
||||
}
|
||||
}
|
||||
.set(USERS.SECONDS_PLAYED, apiUser.statistics?.play_time)
|
||||
.set(USERS.SECONDS_PLAYED, userStatistics?.play_time)
|
||||
.set(USERS.COUNTRY, apiUser.country?.code)
|
||||
.set(USERS.COUNTRY_RANK, apiUser.statistics?.country_rank)
|
||||
.set(USERS.PLAYCOUNT, apiUser.statistics?.play_count)
|
||||
.set(USERS.COUNTRY_RANK, userStatistics?.country_rank)
|
||||
.set(USERS.PLAYCOUNT, userStatistics?.play_count)
|
||||
.set(USERS.SYS_LAST_UPDATE, OffsetDateTime.now(ZoneOffset.UTC))
|
||||
.where(USERS.USER_ID.eq(apiUser.id))
|
||||
.execute()
|
||||
@ -108,23 +110,23 @@ class UserService(
|
||||
val affectedRows = dslContext.insertInto(USERS)
|
||||
.set(USERS.USER_ID, apiUser.id)
|
||||
.set(USERS.USERNAME, apiUser.username)
|
||||
.set(USERS.RANK, apiUser.statistics?.global_rank)
|
||||
.set(USERS.PP_RAW, apiUser.statistics?.pp)
|
||||
.set(USERS.ACCURACY, apiUser.statistics?.hit_accuracy)
|
||||
.set(USERS.TOTAL_SCORE, apiUser.statistics?.total_score)
|
||||
.set(USERS.RANKED_SCORE, apiUser.statistics?.ranked_score)
|
||||
.set(USERS.COUNT_300, apiUser.statistics?.count_300)
|
||||
.set(USERS.COUNT_100, apiUser.statistics?.count_100)
|
||||
.set(USERS.COUNT_50, apiUser.statistics?.count_50)
|
||||
.set(USERS.RANK, userStatistics?.global_rank)
|
||||
.set(USERS.PP_RAW, userStatistics?.pp)
|
||||
.set(USERS.ACCURACY, userStatistics?.hit_accuracy)
|
||||
.set(USERS.TOTAL_SCORE, userStatistics?.total_score)
|
||||
.set(USERS.RANKED_SCORE, userStatistics?.ranked_score)
|
||||
.set(USERS.COUNT_300, userStatistics?.count_300)
|
||||
.set(USERS.COUNT_100, userStatistics?.count_100)
|
||||
.set(USERS.COUNT_50, userStatistics?.count_50)
|
||||
.apply {
|
||||
if(apiUser.join_date != null) {
|
||||
set(USERS.JOIN_DATE, OffsetDateTime.parse(apiUser.join_date).toLocalDateTime())
|
||||
}
|
||||
}
|
||||
.set(USERS.SECONDS_PLAYED, apiUser.statistics?.play_time)
|
||||
.set(USERS.SECONDS_PLAYED, userStatistics?.play_time)
|
||||
.set(USERS.COUNTRY, apiUser.country?.code)
|
||||
.set(USERS.COUNTRY_RANK, apiUser.statistics?.country_rank)
|
||||
.set(USERS.PLAYCOUNT, apiUser.statistics?.play_count)
|
||||
.set(USERS.COUNTRY_RANK, userStatistics?.country_rank)
|
||||
.set(USERS.PLAYCOUNT, userStatistics?.play_count)
|
||||
.set(USERS.SYS_LAST_UPDATE, OffsetDateTime.now(ZoneOffset.UTC))
|
||||
.onDuplicateKeyIgnore()
|
||||
.execute()
|
||||
|
||||
@ -11,6 +11,11 @@ class OsuApiModels {
|
||||
val name: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserStatisticsRuleset(
|
||||
val osu: UserStatistics?
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class UserStatistics(
|
||||
val count_100: Long,
|
||||
@ -39,9 +44,16 @@ class OsuApiModels {
|
||||
val join_date: String?,
|
||||
|
||||
val statistics: UserStatistics?,
|
||||
val statistics_rulesets: UserStatisticsRuleset?,
|
||||
|
||||
val country: UserCountry?
|
||||
)
|
||||
) {
|
||||
|
||||
fun getStatistics(): UserStatistics? {
|
||||
return this.statistics ?: this.statistics_rulesets?.osu
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserBatchResponse(
|
||||
|
||||
@ -357,6 +357,7 @@ class ImportScores(
|
||||
}
|
||||
|
||||
this.statistics.totalScores = beatmapScores.scores.size
|
||||
var totalScoresForBeatmap = 0
|
||||
|
||||
for (score in beatmapScores.scores) {
|
||||
this.statistics.currentScore++
|
||||
@ -392,10 +393,12 @@ class ImportScores(
|
||||
continue
|
||||
}
|
||||
|
||||
totalScoresForBeatmap += 1
|
||||
this.updateScoreWeaving(beatmap, score)
|
||||
}
|
||||
|
||||
checkReplaySimilarity(beatmap.id)
|
||||
if(totalScoresForBeatmap > 0)
|
||||
checkReplaySimilarity(beatmap.id)
|
||||
|
||||
dslContext.update(BEATMAPS)
|
||||
.set(BEATMAPS.SYS_LAST_UPDATE, OffsetDateTime.now(ZoneOffset.UTC))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user