tasafo/palestras-coletivas

View on GitHub
app/queries/user_query.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class UserQuery
  def initialize(relation = User.scoped)
    @relation = relation
  end

  def without_the_owner(user)
    @relation.not_in(_id: user).order(slugs: :asc)
  end

  def ranking(type, limit)
    counter = "counter_#{type}".to_sym

    @relation.where(counter.gt => 0).desc(counter).asc(:slugs).limit(limit)
  end
end