From 2e2fcc6c64a295cc2bf9eedf7dfab4df71d40975 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 5 Dec 2025 13:50:09 +0100 Subject: [PATCH] Lower the rate limit --- Blacklight/PopulateAniList.php | 4 ++-- app/Console/Commands/RefreshAnimeData.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Blacklight/PopulateAniList.php b/Blacklight/PopulateAniList.php index 7103d7d1c..ec87e3a8a 100644 --- a/Blacklight/PopulateAniList.php +++ b/Blacklight/PopulateAniList.php @@ -18,9 +18,9 @@ class PopulateAniList private const API_URL = 'https://graphql.anilist.co'; /** - * Rate limit: 90 requests per minute + * Rate limit: 20 requests per minute (conservative limit to avoid hitting AniList's 90/min limit) */ - private const RATE_LIMIT_PER_MINUTE = 90; + private const RATE_LIMIT_PER_MINUTE = 20; /** * Whether to echo message output. diff --git a/app/Console/Commands/RefreshAnimeData.php b/app/Console/Commands/RefreshAnimeData.php index 06b38fb55..4e12543ca 100644 --- a/app/Console/Commands/RefreshAnimeData.php +++ b/app/Console/Commands/RefreshAnimeData.php @@ -12,10 +12,10 @@ use Illuminate\Support\Facades\DB; class RefreshAnimeData extends Command { /** - * Conservative rate limit: 35 requests per minute (to stay well below AniList's 90/min limit). + * Conservative rate limit: 20 requests per minute (to stay well below AniList's 90/min limit). * This allows for multiple API calls per release (search + getById). */ - private const RATE_LIMIT_PER_MINUTE = 35; + private const RATE_LIMIT_PER_MINUTE = 20; /** * Track API request timestamps for rate limiting. @@ -387,8 +387,8 @@ class RefreshAnimeData extends Command } } - // Calculate minimum delay between requests (to maintain 35/min rate) - // 60 seconds / 35 requests = ~1.71 seconds per request + // Calculate minimum delay between requests (to maintain 20/min rate) + // 60 seconds / 20 requests = 3 seconds per request $minDelay = 60.0 / self::RATE_LIMIT_PER_MINUTE; // If we have recent requests, ensure we wait at least the minimum delay