Skip to content

Commit

Permalink
More fiddling with the pairings generator, courtesy of Elz. Trying to…
Browse files Browse the repository at this point in the history
… make it less of a resource hog.
  • Loading branch information
neuroalien committed Feb 9, 2011
1 parent b416c3f commit 75cd318
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/toys_controller.rb
Expand Up @@ -2,8 +2,8 @@ class ToysController < ApplicationController
# Enigel's experimental toy; don't refresh too much!
def brainhurter
if current_user.is_a?(User)
@crtUserFandoms = ( (current_user.tags.uniq.select {|t| t.is_a?(Fandom) && t.canonical?}) + (current_user.tags.uniq.select {|t| t.is_a?(Fandom) && t.merger}.collect(&:merger)) ).uniq
@crtUserCharas = ( (current_user.tags.uniq.select {|t| t.is_a?(Character) && t.canonical?}) + (current_user.tags.uniq.select {|t| t.is_a?(Character) && t.merger}.collect(&:merger)) ).uniq
@crtUserFandoms = current_user.filters.by_type("Fandom").group(:id) - [Fandom.find_by_name("No Fandom")]
@crtUserCharas = current_user.filters.by_type("Character").group(:id)

if !params[:level].blank? && params[:level].to_s.downcase == "kamikaze"
@crtUserSum = (@crtUserFandoms.collect {|f| f.characters.canonical} + @crtUserCharas).flatten.uniq
Expand All @@ -12,7 +12,7 @@ def brainhurter
pool = Array.new(@crtUserCharas)
end

if @crtUserFandoms.size < 2 || pool.size < 2
if @crtUserFandoms.length < 2 || pool.length < 2
flash[:error] = "Sorry, you need to have written in at least two different fandoms, at least two different characters!"
else
if !params[:pairings_count].blank? && ["5","10","15","20"].include?(params[:pairings_count])
Expand Down
2 changes: 1 addition & 1 deletion app/views/toys/brainhurter.html.erb
@@ -1,6 +1,6 @@
<h2>Roll-your-own Brainhurt Pairing Generator</h2>

<% form_tag "/brainhurter", :method => :post do %>
<% form_tag "/toys/brainhurter", :method => :post do %>
<%= label_tag "level_normal", "Use your written characters" %>
<%= radio_button_tag "level", "normal", params[:level] == "normal" %>
<%= label_tag "level_kamikaze", "Use all the characters in your written fandoms" %>
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Expand Up @@ -426,6 +426,8 @@
end
end
resources :search, :only => :index

resources :toys, :only => :brainhurter

match 'search' => 'search#index'
match 'support' => 'feedbacks#create', :as => 'feedbacks', :via => [:post]
Expand Down

0 comments on commit 75cd318

Please sign in to comment.