Merge pull request #1017 from keriati/fix/appupdatereduce

fix: Throttle app updates when updating to new version.
This commit is contained in:
KodeStar 2022-11-20 20:44:43 +00:00 committed by GitHub
commit 68c8dbc33a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -3,6 +3,7 @@
namespace App\Providers; namespace App\Providers;
use App\Application; use App\Application;
use App\Item;
use App\Jobs\ProcessApps; use App\Jobs\ProcessApps;
use App\Setting; use App\Setting;
use App\User; use App\User;
@ -169,10 +170,16 @@ class AppServiceProvider extends ServiceProvider
*/ */
private function updateApps() private function updateApps()
{ {
Log::debug('Update of all apps triggered'); Log::debug('Update of apps triggered');
$items = Item::whereNotNull('appid')->get('appid')->toArray();
$items = array_unique($items, SORT_REGULAR);
foreach (Application::all(['appid']) as $app) { // We onl update the apps that are actually in use by items
Application::getApp($app->appid); // 1 sec delay after each update to throttle the requests
// Todo: move this to some background task?
foreach ($items as $itemKey => $item) {
Application::getApp($item['appid']);
usleep(250000);
} }
} }
} }

File diff suppressed because one or more lines are too long