diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/ImportUsers.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/ImportUsers.kt index a7c8175..855f365 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/ImportUsers.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/scheduler/ImportUsers.kt @@ -27,7 +27,7 @@ class ImportUsers( companion object { - const val SLEEP_AFTER_API_CALL = 1000L + const val SLEEP_AFTER_API_CALL = 3000L } @@ -53,7 +53,7 @@ class ImportUsers( private fun updateUsers() { // Fetch 50 users with the oldest last update time - // We exclude all users with at least 1 banned score in the last 3 months + val threeMonthsAgo = LocalDateTime.now().minusMonths(3) val bannedUsersCondition = SCORES.IS_BANNED.eq(true) @@ -62,8 +62,7 @@ class ImportUsers( val userIds = dslContext .select(USERS.USER_ID) .from(USERS) - .leftJoin(SCORES).on(USERS.USER_ID.eq(SCORES.USER_ID).and(bannedUsersCondition)) - .where(SCORES.USER_ID.isNull) + .leftJoin(SCORES).on(USERS.USER_ID.eq(SCORES.USER_ID)) .orderBy(USERS.SYS_LAST_UPDATE.asc()) .limit(50) .fetchInto(Long::class.java) @@ -78,6 +77,11 @@ class ImportUsers( // Check which ids are missing; if any are missing, we explicitly check if they're banned. val missingIds = userIds.filter { it !in usersResult.users.map { it.id } } for (missingId in missingIds) { + // We exclude all users with at least 1 banned score in the last 3 months + if(dslContext.fetchExists(SCORES, SCORES.USER_ID.eq(missingId).and(bannedUsersCondition))) { + continue + } + val isUserBanned = this.osuApi.checkIfUserBanned(missingId) Thread.sleep(SLEEP_AFTER_API_CALL) if (isUserBanned == true) {