Skip to content

Commit

Permalink
Add scope to filter lobbies with accepted events
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaCheca committed Jul 27, 2018
1 parent 9eeec29 commit a44416c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class OrganizationsController < ApplicationController
def index
@organizations = search(params)
@paginated_organizations = Organization.lobbies.where(id: @organizations.hits.map(&:primary_key))
@paginated_organizations = @paginated_organizations.with_accepted_events if params[:lobby_activity].present?
@paginated_organizations = @paginated_organizations.reorder(sorting_option(params[:order]))

end
Expand Down
1 change: 1 addition & 0 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Organization < ActiveRecord::Base
scope :validated, -> { where('invalidated_at is null') }
scope :lobbies, -> { where('entity_type = ?', 2) }
scope :full_like, ->(name) { where("identifier ilike ? OR name ilike ? OR first_surname ilike ?", name, name, name) }
scope :with_accepted_events, -> { joins(:events).where("events.status IN (?)", [1,2]) }

def entity_type_id
Organization.entity_types[entity_type]
Expand Down

0 comments on commit a44416c

Please sign in to comment.