Ho trovato questo argomento durante la ricerca prima di segnalare un bug, quindi lo aggiungo.
TL;DR la query per la notifica è errata perché conta anche gli utenti rifiutati.
Notifica: 16 utenti in attesa di approvazione, fai clic sul link, ne vedi solo 2.
La query utilizzata per la notifica è questa
puts AdminUserIndexQuery.new(query: "pending", stats: false).find_users_query.to_sql
SELECT "users".* FROM "users"
WHERE (suspended_till IS NULL OR suspended_till <= '2023-11-13 11:05:23.225614')
AND "users"."approved" = FALSE
AND "users"."active" = TRUE
ORDER BY users.created_at DESC,users.username
che, nel mio caso, mi restituisce 16 utenti
[4479, 4472, 4456, 4446, 4443, 4430, 4302, 4291, 4206, 4199, 4178, 4168, 4131, 4061, 3677, 3642]
Inserendo questi ID nella coda di Reviewables, ottengo 2 utenti che devono effettivamente essere approvati (stato 0) e 14 utenti che sono già stati rifiutati (stato 2)
ReviewableUser.where(type: 'ReviewableUser')
.where(target_id: ids)
.pluck(:target_id, :status)
[[3642, 2], [3677, 2], [4061, 2], [4131, 2], [4168, 2],
[4178, 2], [4199, 2], [4206, 2], [4291, 2], [4302, 2],
[4430, 2], [4443, 2], [4446, 2], [4456, 2], [4472, 0], [4479, 0]]