Avoid showing banned user's stolen plays when score imports are out of order

Would prefer this to be handled in the importer, but it's enough of an
edge-case to just have it here for now.
This commit is contained in:
Stedoss 2025-05-06 15:32:32 +09:00
parent b4824ce81f
commit 1faa80a1db
2 changed files with 13 additions and 0 deletions

View File

@ -65,6 +65,8 @@ data class SimilarReplayEntry(
val replay_id_2: Long,
val user_id_1: Long,
val user_id_2: Long,
val user_banned_1: Boolean,
val user_banned_2: Boolean,
val username_1: String,
val username_2: String,
val beatmap_beatmapset_id: Long,

View File

@ -390,6 +390,8 @@ class ScoreService(
fun getSimilarReplays(condition: Condition = DSL.noCondition()): List<SimilarReplayEntry> {
val replays = getSimilarReplaysRecords(condition)
return mapSimilarReplays(replays)
// Filter scores where the imports have been out of order and the stolen replay's user has been banned
.filter { !it.user_banned_2 }
}
private fun mapSimilarReplays(replays: List<Record>) = replays.map {
@ -400,6 +402,9 @@ class ScoreService(
var userId1 = it.get(osuScoreAlias1.USER_ID, Long::class.java)
var userId2 = it.get(osuScoreAlias2.USER_ID, Long::class.java)
var userBanned1 = it.get(osuUserAlias1.IS_BANNED, Boolean::class.java)
var userBanned2 = it.get(osuUserAlias2.IS_BANNED, Boolean::class.java)
var username1 = it.get(osuUserAlias1.USERNAME, String::class.java)
var username2 = it.get(osuUserAlias2.USERNAME, String::class.java)
@ -422,6 +427,10 @@ class ScoreService(
userId1 = userId2
userId2 = tempUserId
val tempUserBanned = userBanned1
userBanned1 = userBanned2
userBanned2 = tempUserBanned
val tempUsername = username1
username1 = username2
username2 = tempUsername
@ -444,6 +453,8 @@ class ScoreService(
replay_id_2 = replayId2,
user_id_1 = userId1,
user_id_2 = userId2,
user_banned_1 = userBanned1,
user_banned_2 = userBanned2,
username_1 = username1,
username_2 = username2,
beatmap_beatmapset_id = it.get(BEATMAPS.BEATMAPSET_ID, Long::class.java),