From 7caed381fb784c0b228423888b69d1fb38dbfbe7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 4 Feb 2024 02:40:04 -0700 Subject: [PATCH] Update AP helpers, more efficently update post counts --- .../Commands/AccountPostCountStatUpdate.php | 57 +++++++++++++++++++ app/Console/Kernel.php | 3 +- app/Services/Account/AccountStatService.php | 26 +++++++++ app/Util/ActivityPub/Helpers.php | 3 +- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 app/Console/Commands/AccountPostCountStatUpdate.php create mode 100644 app/Services/Account/AccountStatService.php diff --git a/app/Console/Commands/AccountPostCountStatUpdate.php b/app/Console/Commands/AccountPostCountStatUpdate.php new file mode 100644 index 000000000..6d5ba00a6 --- /dev/null +++ b/app/Console/Commands/AccountPostCountStatUpdate.php @@ -0,0 +1,57 @@ +count(); + if($statusCount != $acct['statuses_count']) { + $profile = Profile::find($id); + if(!$profile) { + AccountStatService::removeFromPostCount($id); + continue; + } + $profile->status_count = $statusCount; + $profile->save(); + AccountService::del($id); + } + AccountStatService::removeFromPostCount($id); + } + return; + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index aadaa1f7a..7953ea783 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -38,7 +38,7 @@ class Kernel extends ConsoleKernel } if(config('import.instagram.enabled')) { - $schedule->command('app:transform-imports')->everyFourMinutes(); + $schedule->command('app:transform-imports')->everyTenMinutes(); $schedule->command('app:import-upload-garbage-collection')->hourlyAt(51); $schedule->command('app:import-remove-deleted-accounts')->hourlyAt(37); $schedule->command('app:import-upload-clean-storage')->twiceDailyAt(1, 13, 32); @@ -49,6 +49,7 @@ class Kernel extends ConsoleKernel } $schedule->command('app:notification-epoch-update')->weeklyOn(1, '2:21'); $schedule->command('app:hashtag-cached-count-update')->hourlyAt(25); + $schedule->command('app:account-post-count-stat-update')->everySixHours(25); } /** diff --git a/app/Services/Account/AccountStatService.php b/app/Services/Account/AccountStatService.php new file mode 100644 index 000000000..0b5d45a3e --- /dev/null +++ b/app/Services/Account/AccountStatService.php @@ -0,0 +1,26 @@ +onQueue('low'); + AccountStatService::incrementPostCount($pid); if( $status->in_reply_to_id === null && in_array($status->type, ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])