From 7cfbd891aefa31d9b8374e9823a075e6ea0bdfcb Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 15 Feb 2022 18:49:23 -0600 Subject: [PATCH] pixiv: avoid unnecessary API call when uploading Pixiv posts. Do one less API call when fetching the image URLs for a Pixiv post. The `is_ugoira?` check in `image_urls` caused us to do an extra API call when fetching the image URLs for a non-ugoira post. API calls to Pixiv take around ~800ms, so this reduces minimum upload time for Pixiv posts from ~1.6 seconds (two calls) to ~0.8 seconds. --- app/logical/sources/strategies/pixiv.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb index 47d30d091..7745a1f9e 100644 --- a/app/logical/sources/strategies/pixiv.rb +++ b/app/logical/sources/strategies/pixiv.rb @@ -223,7 +223,7 @@ module Sources def is_ugoira? # https://i.pximg.net/img-original/img/2019/05/27/17/59/33/74932152_ugoira0.jpg - url.match?(UGOIRA) || api_illust.dig(:urls, :original)&.match?(/ugoira/) + url.match?(UGOIRA) || original_urls&.any?(/ugoira/) end def illust_id