Tweaked import:users logic
This commit is contained in:
parent
9cea7e66a4
commit
5794b5a2fb
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user