Sha256: 050c9d0363958dad177fe2246f56fb6eb49564ca0e13432ba57e5854c66d9c65

Contents?: true

Size: 545 Bytes

Versions: 8

Compression:

Stored size: 545 Bytes

Contents

module Dune::Admin::UserConcern
  extend ActiveSupport::Concern

  included do
    scope :by_email, ->(email){ where('email ~* ?', email) }
    scope :by_name, ->(name){ where('users.name ~* ?', name) }
    scope :by_id, ->(id){ where(id: id) }
    scope :by_key, ->(key){ where('EXISTS(SELECT true FROM contributions WHERE contributions.user_id = users.id AND contributions.key ~* ?)', key) }
    scope :has_credits, -> { joins(:user_total).where('user_totals.credits > 0') }
    scope :order_by, ->(sort_field){ order(sort_field) }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dune-admin-1.2.7 app/models/dune/admin/user_concern.rb
dune-admin-1.2.6 app/models/dune/admin/user_concern.rb
dune-admin-1.2.5 app/models/dune/admin/user_concern.rb
dune-admin-1.2.4 app/models/dune/admin/user_concern.rb
dune-admin-1.2.3 app/models/dune/admin/user_concern.rb
dune-admin-1.0.0 app/models/dune/admin/user_concern.rb
dune-admin-1.2.1 app/models/dune/admin/user_concern.rb
dune-admin-1.2.0 app/models/dune/admin/user_concern.rb