From b679efbd2bb99c79c8fb44b079a5b6f9fdfd6532 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Mon, 17 Oct 2016 22:36:32 +0300 Subject: [PATCH] Reimplement speaker listing --- app/controllers/api/speakers_controller.rb | 2 +- app/models/conference.rb | 3 +-- app/models/event.rb | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/speakers_controller.rb b/app/controllers/api/speakers_controller.rb index 33f4cde..7fe7399 100644 --- a/app/controllers/api/speakers_controller.rb +++ b/app/controllers/api/speakers_controller.rb @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index 44cddb1..47eeb30 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -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 diff --git a/app/models/event.rb b/app/models/event.rb index 5934622..dc60733 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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