From 7caed381fb784c0b228423888b69d1fb38dbfbe7 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 4 Feb 2024 02:40:04 -0700 Subject: [PATCH 1/2] 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']) From ddf7f09ad41bd2b935ebfb360286e48a4c6370f0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 4 Feb 2024 02:40:59 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc42cb51f..c37659fba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ - Update ApiV1Controller, properly cast boolean sensitive parameter. Fixes #4888 ([0aff126a](https://github.com/pixelfed/pixelfed/commit/0aff126a)) - Update AccountImport.vue, fix new IG export format ([59aa6a4b](https://github.com/pixelfed/pixelfed/commit/59aa6a4b)) - Update TransformImports command, fix import service condition ([32c59f04](https://github.com/pixelfed/pixelfed/commit/32c59f04)) +- Update AP helpers, more efficently update post count ([7caed381](https://github.com/pixelfed/pixelfed/commit/7caed381)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)