@users = User.registred
.includes(:items)
.joins('LEFT OUTER JOIN items ON users.id=items.user_id')
.group(User.column_names.collect do |c| "#{User.table_name}.#{c}" end.join(','))
.order('CASE WHEN LENGTH(users.profile_picture) > 0 THEN 0 ELSE 1 END, followers_count DESC, bibbed_items_count DESC, SUM(items.user_likes_count) DESC, users.id')
在哪里registered = where("deactivated_at IS NULL AND last_sign_in_at IS NOT NULL")
Kaminari 不使用组子句。如何优化此查询中的组子句?