From 3398439bae24923d57d49f72d9aea7b7d5536cc9 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 12 Oct 2023 18:57:39 -0700 Subject: [PATCH] Fix more modeling bugs Just find_all_by's that I never cleaned up Oddly enough, I still got a "neopets seems down" message out of this, idk if that's an actual bug or just sluggishness rn --- app/models/item.rb | 5 +++-- app/models/pet_state.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/item.rb b/app/models/item.rb index 31056860..7ffb4a55 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -561,7 +561,8 @@ class Item < ApplicationRecord # Collect existing relationships existing_relationships_by_item_id_and_swf_asset_id = {} - existing_items = scope.find_all_by_id(item_ids, :include => :parent_swf_asset_relationships) + existing_items = scope.where(id: item_ids). + include(:parent_swf_asset_relationships) existing_items.each do |item| items[item.id] = item relationships_by_swf_asset_id = {} @@ -578,7 +579,7 @@ class Item < ApplicationRecord swf_asset_ids << asset_id.to_i if asset_data end existing_swf_assets = SwfAsset.object_assets.includes(:zone). - find_all_by_remote_id swf_asset_ids + where(remote_id: swf_asset_ids) existing_swf_assets_by_remote_id = {} existing_swf_assets.each do |swf_asset| existing_swf_assets_by_remote_id[swf_asset.remote_id] = swf_asset diff --git a/app/models/pet_state.rb b/app/models/pet_state.rb index 22913aff..e92ffe41 100644 --- a/app/models/pet_state.rb +++ b/app/models/pet_state.rb @@ -168,7 +168,7 @@ class PetState < ApplicationRecord ) end existing_swf_assets = SwfAsset.biology_assets.includes(:zone). - find_all_by_remote_id(swf_asset_ids) + where(remote_id: swf_asset_ids) existing_swf_assets_by_id = {} existing_swf_assets.each do |swf_asset| existing_swf_assets_by_id[swf_asset.remote_id] = swf_asset