Nuke all API-related files
This commit is contained in:
parent
e930e51f48
commit
4fe67060c9
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -1,9 +0,0 @@
|
|||
class Ratings
|
||||
def initialize
|
||||
@ratings = {}
|
||||
end
|
||||
|
||||
def [](id)
|
||||
@ratings[id] ||= SelectedTalk.where(talk_id: id).count
|
||||
end
|
||||
end
|
|
@ -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
|
|
@ -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 -%>
|
|
@ -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 -%>
|
|
@ -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 -%>
|
|
@ -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 %>
|
|
@ -1,13 +0,0 @@
|
|||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Event</th>
|
||||
<% @talks.each |talk| do %>
|
||||
<th><%= talk.title %> (<%= talk.id %>)</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= render partial: 'conflict_coefficient', collection: @conflict_coefficients %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -1,3 +0,0 @@
|
|||
<%- headers = ['ID', 'Created at', 'Talk'] -%>
|
||||
<%= CSV.generate_line headers -%>
|
||||
<%= render partial: 'talk_preference', collection: @talk_preferences %>
|
|
@ -1,3 +0,0 @@
|
|||
<%- headers = ['ID', 'Type', 'Title', 'Subtitle', 'Votes', '%'] -%>
|
||||
<%= CSV.generate_line headers -%>
|
||||
<%= render partial: 'talk', collection: @talks %>
|
|
@ -1,24 +0,0 @@
|
|||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Type</th>
|
||||
<th>Title</th>
|
||||
<th>Subtitle</th>
|
||||
<th>Votes</th>
|
||||
<th>%</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @talks.each do |talk| %>
|
||||
<tr class="rating">
|
||||
<td><%= talk.id %></td>
|
||||
<td><%= talk.event_type.name %></td>
|
||||
<td><%= talk.title %></td>
|
||||
<td><%= talk.subtitle %></td>
|
||||
<td><%= @ratings[talk.id] %></td>
|
||||
<td><%= "%.2f%" % Rational(100 * @ratings[talk.id], @votes_count).to_f %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -1 +0,0 @@
|
|||
json.merge! @summary.summary
|
Loading…
Reference in New Issue