2014-09-30 13:34:09 +03:00
|
|
|
class SuggestionGroup
|
|
|
|
include ActiveModel::Model
|
|
|
|
attr_accessor :speaker, :suggestions
|
|
|
|
|
|
|
|
def self.where(conditions = {})
|
|
|
|
Event.joins(:track).includes(:user).where(conditions).group_by(&:user).map do |speaker, suggestions|
|
|
|
|
SuggestionGroup.new speaker: speaker, suggestions: suggestions
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-10-10 19:10:34 +03:00
|
|
|
def self.for_conference(conference, conditions = {})
|
|
|
|
where conditions.merge({tracks: {conference_id: conference.id}})
|
2014-09-30 13:34:09 +03:00
|
|
|
end
|
|
|
|
end
|