From 4fe67060c9982d362f0bef52c20641bc12506f26 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Mon, 10 Oct 2016 20:23:05 +0300 Subject: [PATCH] Nuke all API-related files --- app/controllers/conflicts_controller.rb | 13 ------- app/models/conference_summary.rb | 17 ---------- app/models/conflict_coefficient.rb | 45 ------------------------- app/models/ratings.rb | 9 ----- app/models/summary.rb | 23 ------------- app/views/conflicts/index.csv.erb | 5 --- app/views/conflicts/pivot.csv.erb | 5 --- app/views/home/_talk.csv.erb | 1 - app/views/home/_talk.html.erb | 0 app/views/home/_talk_preference.csv.erb | 3 -- app/views/home/conflicts.html.erb | 13 ------- app/views/home/export.csv.erb | 3 -- app/views/home/ratings.csv.erb | 3 -- app/views/home/ratings.html.erb | 24 ------------- app/views/home/summary.json.jbuilder | 1 - 15 files changed, 165 deletions(-) delete mode 100644 app/controllers/conflicts_controller.rb delete mode 100644 app/models/conference_summary.rb delete mode 100644 app/models/conflict_coefficient.rb delete mode 100644 app/models/ratings.rb delete mode 100644 app/models/summary.rb delete mode 100644 app/views/conflicts/index.csv.erb delete mode 100644 app/views/conflicts/pivot.csv.erb delete mode 100644 app/views/home/_talk.csv.erb delete mode 100644 app/views/home/_talk.html.erb delete mode 100644 app/views/home/_talk_preference.csv.erb delete mode 100644 app/views/home/conflicts.html.erb delete mode 100644 app/views/home/export.csv.erb delete mode 100644 app/views/home/ratings.csv.erb delete mode 100644 app/views/home/ratings.html.erb delete mode 100644 app/views/home/summary.json.jbuilder diff --git a/app/controllers/conflicts_controller.rb b/app/controllers/conflicts_controller.rb deleted file mode 100644 index 596bab3..0000000 --- a/app/controllers/conflicts_controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index ef34a98..0000000 --- a/app/models/conference_summary.rb +++ /dev/null @@ -1,17 +0,0 @@ -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/conflict_coefficient.rb b/app/models/conflict_coefficient.rb deleted file mode 100644 index 682786b..0000000 --- a/app/models/conflict_coefficient.rb +++ /dev/null @@ -1,45 +0,0 @@ -class ConflictCoefficient - attr_reader :left, :right - - def self.all - Talk.find(:all, from: :halfnarp_friendly).map(&:id).combination(2).map do |talks| - ConflictCoefficient.new talks.first, talks.last - end - end - - def self.all_as_hash - conflicts_hash = {} - - all.each do |coefficient| - conflicts_hash[coefficient.left] = {} unless conflicts_hash[coefficient.left] - conflicts_hash[coefficient.left][coefficient.right] = coefficient.per_cent - end - - conflicts_hash - end - - def conflicts - talk_preferences.joins('INNER JOIN "selected_talks" AS "left" - ON "left"."talk_preference_id" = "talk_preferences"."unique_id" - INNER JOIN "selected_talks" AS "right" - ON "right"."talk_preference_id" = "talk_preferences"."unique_id"').where(left: {talk_id: @left}, right: {talk_id: @right}).count - end - - def total_votes - talk_preferences.count - end - - def initialize(left, right) - @left, @right = left, right - end - - def per_cent - Rational(100 * conflicts, total_votes).to_f - end - - private - - def talk_preferences - @talk_preferences ||= TalkPreference.this_years - end -end diff --git a/app/models/ratings.rb b/app/models/ratings.rb deleted file mode 100644 index 920f123..0000000 --- a/app/models/ratings.rb +++ /dev/null @@ -1,9 +0,0 @@ -class Ratings - def initialize - @ratings = {} - end - - def [](id) - @ratings[id] ||= SelectedTalk.where(talk_id: id).count - end -end diff --git a/app/models/summary.rb b/app/models/summary.rb deleted file mode 100644 index 165c937..0000000 --- a/app/models/summary.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Summary - def initialize(params = {}) - @talk_id, @other_talk_ids = params[:talk_id], params[:other_talk_ids] - @votes_count = SelectedTalk.where(talk_id: @talk_id).count - @all_votes_count = TalkPreference.joins(:selected_talks).where(selected_talks: {talk_id: @other_talk_ids << @talk_id}).uniq.count - end - - def summary - { - talk_id: @talk_id, - votes: @votes_count, - all_votes: @all_votes_count, - per_cent: Rational(@votes_count, @all_votes_count).to_f, - conflicts: conflicts - } - end - - def conflicts - @other_talk_ids.map do |right| - [right, ConflictCoefficient.new(@talk_id, right).conflicts] - end.sort_by(&:last).to_h - end -end diff --git a/app/views/conflicts/index.csv.erb b/app/views/conflicts/index.csv.erb deleted file mode 100644 index b9804ff..0000000 --- a/app/views/conflicts/index.csv.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%- 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/conflicts/pivot.csv.erb b/app/views/conflicts/pivot.csv.erb deleted file mode 100644 index 95029a5..0000000 --- a/app/views/conflicts/pivot.csv.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%- 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/_talk.csv.erb b/app/views/home/_talk.csv.erb deleted file mode 100644 index 6cf9741..0000000 --- a/app/views/home/_talk.csv.erb +++ /dev/null @@ -1 +0,0 @@ -<%= CSV.generate_line([talk.id, talk.event_type.name, talk.title, talk.subtitle, @ratings[talk.id], "%.2f%" % Rational(100 * @ratings[talk.id], @votes_count).to_f]).html_safe -%> diff --git a/app/views/home/_talk.html.erb b/app/views/home/_talk.html.erb deleted file mode 100644 index e69de29..0000000 diff --git a/app/views/home/_talk_preference.csv.erb b/app/views/home/_talk_preference.csv.erb deleted file mode 100644 index 79dff36..0000000 --- a/app/views/home/_talk_preference.csv.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% talk_preference.talks.each do |talk| %> - <%= CSV.generate_line([talk_preference.hashed_unique_id, talk_preference.created_at, talk]).html_safe -%> -<% end %> diff --git a/app/views/home/conflicts.html.erb b/app/views/home/conflicts.html.erb deleted file mode 100644 index 10abc5a..0000000 --- a/app/views/home/conflicts.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - <% @talks.each |talk| do %> - - <% end %> - - - - <%= render partial: 'conflict_coefficient', collection: @conflict_coefficients %> - -
Event<%= talk.title %> (<%= talk.id %>)
diff --git a/app/views/home/export.csv.erb b/app/views/home/export.csv.erb deleted file mode 100644 index 56469cb..0000000 --- a/app/views/home/export.csv.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%- headers = ['ID', 'Created at', 'Talk'] -%> -<%= CSV.generate_line headers -%> -<%= render partial: 'talk_preference', collection: @talk_preferences %> diff --git a/app/views/home/ratings.csv.erb b/app/views/home/ratings.csv.erb deleted file mode 100644 index dab9902..0000000 --- a/app/views/home/ratings.csv.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%- headers = ['ID', 'Type', 'Title', 'Subtitle', 'Votes', '%'] -%> -<%= CSV.generate_line headers -%> -<%= render partial: 'talk', collection: @talks %> diff --git a/app/views/home/ratings.html.erb b/app/views/home/ratings.html.erb deleted file mode 100644 index 452d134..0000000 --- a/app/views/home/ratings.html.erb +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - <% @talks.each do |talk| %> - - - - - - - - - <% end %> - -
IDTypeTitleSubtitleVotes%
<%= talk.id %><%= talk.event_type.name %><%= talk.title %><%= talk.subtitle %><%= @ratings[talk.id] %><%= "%.2f%" % Rational(100 * @ratings[talk.id], @votes_count).to_f %>
diff --git a/app/views/home/summary.json.jbuilder b/app/views/home/summary.json.jbuilder deleted file mode 100644 index 525c250..0000000 --- a/app/views/home/summary.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.merge! @summary.summary