diff --git a/app/controllers/outfits_controller.rb b/app/controllers/outfits_controller.rb index 63bac124..1a42cc5c 100644 --- a/app/controllers/outfits_controller.rb +++ b/app/controllers/outfits_controller.rb @@ -46,30 +46,28 @@ class OutfitsController < ApplicationController @species = Species.alphabetical end - unless localized_fragment_exist?('outfits#new newest_items') - newest_items = Item.newest.select([:id, :updated_at, :thumbnail_url, :rarity_index]). - includes(:translations).limit(18) - @newest_modeled_items, @newest_unmodeled_items = - newest_items.partition(&:predicted_fully_modeled?) + newest_items = Item.newest.select([:id, :updated_at, :thumbnail_url, :rarity_index]). + includes(:translations).limit(18) + @newest_modeled_items, @newest_unmodeled_items = + newest_items.partition(&:predicted_fully_modeled?) - @newest_unmodeled_items_predicted_missing_species_by_color = {} - @newest_unmodeled_items_predicted_modeled_ratio = {} - @newest_unmodeled_items.each do |item| - h = item.predicted_missing_nonstandard_body_ids_by_species_by_color( - Color.includes(:translations).select([:id]), - Species.includes(:translations).select([:id])) - standard_body_ids_by_species = item. - predicted_missing_standard_body_ids_by_species( - Species.select([:id]).includes(:translations)) - if standard_body_ids_by_species.present? - h[:standard] = standard_body_ids_by_species - end - @newest_unmodeled_items_predicted_missing_species_by_color[item] = h - @newest_unmodeled_items_predicted_modeled_ratio[item] = item.predicted_modeled_ratio + @newest_unmodeled_items_predicted_missing_species_by_color = {} + @newest_unmodeled_items_predicted_modeled_ratio = {} + @newest_unmodeled_items.each do |item| + h = item.predicted_missing_nonstandard_body_ids_by_species_by_color( + Color.includes(:translations).select([:id]), + Species.includes(:translations).select([:id])) + standard_body_ids_by_species = item. + predicted_missing_standard_body_ids_by_species( + Species.select([:id]).includes(:translations)) + if standard_body_ids_by_species.present? + h[:standard] = standard_body_ids_by_species end - - @species_count = Species.count + @newest_unmodeled_items_predicted_missing_species_by_color[item] = h + @newest_unmodeled_items_predicted_modeled_ratio[item] = item.predicted_modeled_ratio end + + @species_count = Species.count unless localized_fragment_exist?('outfits#new latest_contribution') @latest_contribution = Contribution.recent.first diff --git a/app/models/item/create_task.rb b/app/models/item/create_task.rb deleted file mode 100644 index fce4ee49..00000000 --- a/app/models/item/create_task.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Item - class CreateTask - extend FragmentExpiration - - TIMEOUT_IN_SECONDS = 10 - - @queue = :item_create - - def self.perform(id) - Timeout::timeout(TIMEOUT_IN_SECONDS) do - expire_newest_items - end - end - - def self.expire_newest_items - expire_fragment_in_all_locales('outfits#new newest_items') - end - end -end \ No newline at end of file diff --git a/app/models/item/destroy_task.rb b/app/models/item/destroy_task.rb deleted file mode 100644 index ca14d3b5..00000000 --- a/app/models/item/destroy_task.rb +++ /dev/null @@ -1,16 +0,0 @@ -class Item - class DestroyTask - extend FragmentExpiration - - TIMEOUT_IN_SECONDS = 10 - - @queue = :item_destroy - - def self.perform(id) - Timeout::timeout(TIMEOUT_IN_SECONDS) do - # TODO: it's kinda ugly to reach across classes like this - CreateTask.expire_newest_items - end - end - end -end \ No newline at end of file diff --git a/app/models/item_observer.rb b/app/models/item_observer.rb deleted file mode 100644 index a3ac5eb5..00000000 --- a/app/models/item_observer.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ItemObserver < ActionController::Caching::Sweeper - def after_create(item) - Resque.enqueue(Item::CreateTask, item.id) - end - - def after_destroy(item) - Resque.enqueue(Item::DestroyTask, item.id) - end -end diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index 4128b649..d086efb6 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -100,7 +100,6 @@ %abbr#latest-contribution-created-at{:title => @latest_contribution.created_at.getutc.iso8601} #whats-new - -# TODO: cache this entire block? or just request newest items every time? - if @newest_unmodeled_items.present? #modeling-neopets-users{'data-usernames' => @neopets_usernames.to_json} %h3= t '.newest_items.unmodeled.header'