From f5022dd138f1d8a2b175c6532887144a04846bf2 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Thu, 6 Oct 2016 22:45:08 +0300 Subject: [PATCH] Introduce a conflicts controller --- app/controllers/conflicts_controller.rb | 5 +++++ app/views/conflicts/index.csv.erb | 5 +++++ app/views/home/_conflict_coefficient.csv.erb | 1 - app/views/home/conflicts.csv.erb | 3 --- 4 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 app/controllers/conflicts_controller.rb create mode 100644 app/views/conflicts/index.csv.erb delete mode 100644 app/views/home/_conflict_coefficient.csv.erb delete mode 100644 app/views/home/conflicts.csv.erb diff --git a/app/controllers/conflicts_controller.rb b/app/controllers/conflicts_controller.rb new file mode 100644 index 0000000..c76ca33 --- /dev/null +++ b/app/controllers/conflicts_controller.rb @@ -0,0 +1,5 @@ +class ConflictsController < ApplicationController + def index + @talks = Talk.find(:all, from: :halfnarp_friendly).sort_by(&:title) + end +end diff --git a/app/views/conflicts/index.csv.erb b/app/views/conflicts/index.csv.erb new file mode 100644 index 0000000..b9804ff --- /dev/null +++ b/app/views/conflicts/index.csv.erb @@ -0,0 +1,5 @@ +<%- csv_headers = ['Event'] + @talks.map { |talk| [talk.title, talk.id].join(' ') } -%> +<%= CSV.generate_line(csv_headers).html_safe -%> +<%- @talks.each do |left| -%> + <%= CSV.generate_line([[left.title, left.id].join(' ')] + @talks.map { |right| left.id == right.id ? '-' : ConflictCoefficient.new(left.id, right.id).per_cent}).html_safe -%> +<%- end -%> diff --git a/app/views/home/_conflict_coefficient.csv.erb b/app/views/home/_conflict_coefficient.csv.erb deleted file mode 100644 index ea34f37..0000000 --- a/app/views/home/_conflict_coefficient.csv.erb +++ /dev/null @@ -1 +0,0 @@ -<%= CSV.generate_line([conflict_coefficient.left, conflict_coefficient.right, conflict_coefficient.conflicts, conflict_coefficient.per_cent]).html_safe -%> diff --git a/app/views/home/conflicts.csv.erb b/app/views/home/conflicts.csv.erb deleted file mode 100644 index 8f3c4ad..0000000 --- a/app/views/home/conflicts.csv.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%- headers = ['left', 'right', 'conflicts', '%'] -%> -<%= CSV.generate_line headers -%> -<%= render partial: 'conflict_coefficient', collection: @conflict_coefficients %>