Implement a conflicts summary model
This commit is contained in:
parent
a39af296ba
commit
37a414328f
|
@ -0,0 +1,11 @@
|
||||||
|
class ConflictsSummariesController < ApplicationController
|
||||||
|
def show
|
||||||
|
@conflicts_summary = ConflictsSummary.new conflicts_summary_params
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def conflicts_summary_params
|
||||||
|
params.require(:conflicts_summary).permit(talk_ids: [])
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,18 @@
|
||||||
|
class ConflictsSummary
|
||||||
|
include ActiveModel::Model
|
||||||
|
|
||||||
|
attr_accessor :talk_ids
|
||||||
|
|
||||||
|
def talk_ids
|
||||||
|
@talk_ids ||= []
|
||||||
|
end
|
||||||
|
|
||||||
|
def conflicts
|
||||||
|
talk_ids.map do |talk_id|
|
||||||
|
{
|
||||||
|
talk_id: talk_id,
|
||||||
|
conflicts: ConflictsTable.new(talk_id: talk_id, other_talks_ids: talk_ids.reject { |id| id == talk_id }).conflicts
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1 @@
|
||||||
|
json.merge! @conflicts_summary.conflicts
|
|
@ -3,5 +3,6 @@ Rails.application.routes.draw do
|
||||||
root to: 'home#index'
|
root to: 'home#index'
|
||||||
resource :summary, only: :show
|
resource :summary, only: :show
|
||||||
resource :conflicts, only: :show
|
resource :conflicts, only: :show
|
||||||
|
resource :conflicts_summary, only: :show
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue