You can try below rails console query, the active users who have email digests enabled and are due for their next digest email
User.joins(:user_option)
.where("user_options.email_digests = ?", true)
.where("users.suspended_at IS NULL")
.where("COALESCE(users.last_emailed_at, users.created_at) < (NOW() - INTERVAL '1 minute' * user_options.digest_after_minutes)")
.count