From 3ea0842f008f26023ed0c75f809aa2f8835d8c0a Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Tue, 16 Apr 2024 10:10:28 -0700 Subject: [PATCH] Skip loading image hashes for "pets" that start with `@` This is an optimization on top of 9d8f035, in which we skip the network request altogether in this case that we know will and should fail! --- app/models/pet.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/pet.rb b/app/models/pet.rb index 0557fea4..04f6bc1d 100644 --- a/app/models/pet.rb +++ b/app/models/pet.rb @@ -137,6 +137,9 @@ class Pet < ApplicationRecord end def self.fetch_metadata(name, timeout: 10) + # If this is an image hash "pet name", it has no metadata. + return nil if name.start_with?("@") + request = PET_SERVICE.action('getPet').request([name]) send_amfphp_request(request).tap do |data| if data[:name].blank?