diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 171913c..2b83c3d 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -26,3 +26,7 @@ .friend:hover { background: #AFDDFF !important; } + +tr.rating:hover { + background-color: green; +} diff --git a/app/controllers/conflicts_controller.rb b/app/controllers/conflicts_controller.rb index f6dfd82..596bab3 100644 --- a/app/controllers/conflicts_controller.rb +++ b/app/controllers/conflicts_controller.rb @@ -2,4 +2,12 @@ class ConflictsController < ApplicationController def index @talks = Talk.ordered_by_rating end + + def show + end + + def pivot + @talks = Talk.ordered_by_id + @conflict_coefficients = ConflictCoefficient.all + end end diff --git a/app/models/conference_summary.rb b/app/models/conference_summary.rb new file mode 100644 index 0000000..ef34a98 --- /dev/null +++ b/app/models/conference_summary.rb @@ -0,0 +1,17 @@ +class ConferenceSummary + def initialize(params = {}) + @talk_ids = params[:talk_ids] + end + + def number_of_ballots + TalkPreference.joins(:selected_talks) + .where(selected_talks: { + talk_id: @talk_ids + }) + .uniq.count + end + + def ratings + + end +end diff --git a/app/models/summary.rb b/app/models/summary.rb index ed05dd5..165c937 100644 --- a/app/models/summary.rb +++ b/app/models/summary.rb @@ -18,6 +18,6 @@ class Summary def conflicts @other_talk_ids.map do |right| [right, ConflictCoefficient.new(@talk_id, right).conflicts] - end.to_h + end.sort_by(&:last).to_h end end diff --git a/app/models/talk.rb b/app/models/talk.rb index 85c222d..8da3ac2 100644 --- a/app/models/talk.rb +++ b/app/models/talk.rb @@ -4,6 +4,10 @@ class Talk < ActiveResource::Base self.site = "https://cfp.openfest.org/api/conferences/3" self.element_name = "event" + def self.ordered_by_id + find(:all, from: :halfnarp_friendly).sort_by(&:id) + end + def self.ordered_by_rating ratings = Ratings.new find(:all, from: :halfnarp_friendly).sort { |left, right| ratings[right.id] <=> ratings[left.id] } diff --git a/app/views/conflicts/pivot.csv.erb b/app/views/conflicts/pivot.csv.erb new file mode 100644 index 0000000..95029a5 --- /dev/null +++ b/app/views/conflicts/pivot.csv.erb @@ -0,0 +1,5 @@ +<%- headers = ['left', 'right', 'conflicts', '%'] -%> +<%= CSV.generate_line headers -%> +<%- @conflict_coefficients.each do |conflict_coefficient| -%> + <%= CSV.generate_line([conflict_coefficient.left, conflict_coefficient.right, conflict_coefficient.conflicts, conflict_coefficient.per_cent]).html_safe -%> +<%- end -%> diff --git a/app/views/home/conflicts.html.erb b/app/views/home/conflicts.html.erb new file mode 100644 index 0000000..10abc5a --- /dev/null +++ b/app/views/home/conflicts.html.erb @@ -0,0 +1,13 @@ + + + + + <% @talks.each |talk| do %> + + <% end %> + + + + <%= render partial: 'conflict_coefficient', collection: @conflict_coefficients %> + +
Event<%= talk.title %> (<%= talk.id %>)
diff --git a/app/views/home/ratings.html.erb b/app/views/home/ratings.html.erb index d57a9b1..452d134 100644 --- a/app/views/home/ratings.html.erb +++ b/app/views/home/ratings.html.erb @@ -11,7 +11,7 @@ <% @talks.each do |talk| %> - + <%= talk.id %> <%= talk.event_type.name %> <%= talk.title %>