Reimplement speaker listing

This commit is contained in:
Petko Bordjukov 2016-10-17 22:36:32 +03:00
parent 8d2c197124
commit b679efbd2b
3 changed files with 3 additions and 3 deletions

View File

@ -3,6 +3,6 @@ class Api::SpeakersController < Api::ApplicationController
before_filter :require_current_conference!
def index
@speakers = PersonalProfile.joins(user: [{events: [:slot] }]).where(conference: current_conference).uniq
@speakers = PersonalProfile.joins(user: {participations: {event: :proposition}}).where(events: {id: current_conference.approved_events.pluck(:id)}).distinct
end
end

View File

@ -14,8 +14,7 @@ class Conference < ActiveRecord::Base
has_many :halls
has_many :event_types
has_many :events
has_many :approved_events,
-> { joins(:proposition).where(propositions: {status: Proposition.statuses[:approved]}) }, class_name: 'Event'
has_many :approved_events, -> { joins(:proposition).approved }, class_name: 'Event'
has_many :conflict_counts, through: :events
has_many :volunteer_teams
has_many :volunteers

View File

@ -15,6 +15,7 @@ class Event < ActiveRecord::Base
belongs_to :event_type
scope :ranked, -> { where.not(ranked: nil).where.not(votes: nil) }
scope :approved, -> { where(propositions: {status: Proposition.statuses[:approved]})}
validates :conference, presence: true
validates :title, presence: true