Merge pull request #4895 from pixelfed/staging

Update AP helpers, refactor post count decrement logic
This commit is contained in:
daniel 2024-02-04 03:03:16 -07:00 committed by GitHub
commit 2483832754
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 15 additions and 72 deletions

View file

@ -94,6 +94,7 @@
- Update AccountImport.vue, fix new IG export format ([59aa6a4b](https://github.com/pixelfed/pixelfed/commit/59aa6a4b)) - 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 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)) - Update AP helpers, more efficently update post count ([7caed381](https://github.com/pixelfed/pixelfed/commit/7caed381))
- Update AP helpers, refactor post count decrement logic ([b81ae577](https://github.com/pixelfed/pixelfed/commit/b81ae577))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9) ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)

View file

@ -22,9 +22,9 @@ use App\Notification;
use App\Services\AccountService; use App\Services\AccountService;
use App\Services\NetworkTimelineService; use App\Services\NetworkTimelineService;
use App\Services\StatusService; use App\Services\StatusService;
use App\Jobs\ProfilePipeline\DecrementPostCount;
use App\Jobs\MediaPipeline\MediaDeletePipeline; use App\Jobs\MediaPipeline\MediaDeletePipeline;
use Cache; use Cache;
use App\Services\Account\AccountStatService;
class DeleteRemoteStatusPipeline implements ShouldQueue class DeleteRemoteStatusPipeline implements ShouldQueue
{ {
@ -56,10 +56,7 @@ class DeleteRemoteStatusPipeline implements ShouldQueue
{ {
$status = $this->status; $status = $this->status;
if(AccountService::get($status->profile_id, true)) { AccountStatService::decrementPostCount($status->profile_id);
DecrementPostCount::dispatch($status->profile_id)->onQueue('low');
}
NetworkTimelineService::del($status->id); NetworkTimelineService::del($status->id);
StatusService::del($status->id, true); StatusService::del($status->id, true);
Bookmark::whereStatusId($status->id)->delete(); Bookmark::whereStatusId($status->id)->delete();

View file

@ -35,18 +35,7 @@ class DecrementPostCount implements ShouldQueue
*/ */
public function handle() public function handle()
{ {
$id = $this->id; // deprecated
return;
$profile = Profile::find($id);
if(!$profile) {
return 1;
}
$profile->status_count = $profile->status_count ? $profile->status_count - 1 : 0;
$profile->save();
AccountService::del($id);
return 1;
} }
} }

View file

@ -14,42 +14,12 @@ use App\Profile;
use App\Status; use App\Status;
use App\Services\AccountService; use App\Services\AccountService;
class IncrementPostCount implements ShouldQueue, ShouldBeUniqueUntilProcessing class IncrementPostCount implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $id; public $id;
public $timeout = 900;
public $tries = 3;
public $maxExceptions = 1;
public $failOnTimeout = true;
/**
* The number of seconds after which the job's unique lock will be released.
*
* @var int
*/
public $uniqueFor = 3600;
/**
* Get the unique ID for the job.
*/
public function uniqueId(): string
{
return 'propipe:ipc:' . $this->id;
}
/**
* Get the middleware the job should pass through.
*
* @return array<int, object>
*/
public function middleware(): array
{
return [(new WithoutOverlapping("propipe:ipc:{$this->id}"))->shared()->dontRelease()];
}
/** /**
* Create a new job instance. * Create a new job instance.
* *
@ -67,20 +37,7 @@ class IncrementPostCount implements ShouldQueue, ShouldBeUniqueUntilProcessing
*/ */
public function handle() public function handle()
{ {
$id = $this->id; // deprecated
return;
$profile = Profile::find($id);
if(!$profile) {
return 1;
}
$profile->status_count = $profile->status_count + 1;
$profile->last_status_at = now();
$profile->save();
AccountService::del($id);
AccountService::get($id);
return 1;
} }
} }

View file

@ -39,8 +39,8 @@ use App\Services\AccountService;
use App\Services\CollectionService; use App\Services\CollectionService;
use App\Services\StatusService; use App\Services\StatusService;
use App\Jobs\MediaPipeline\MediaDeletePipeline; use App\Jobs\MediaPipeline\MediaDeletePipeline;
use App\Jobs\ProfilePipeline\DecrementPostCount;
use App\Services\NotificationService; use App\Services\NotificationService;
use App\Services\Account\AccountStatService;
class RemoteStatusDelete implements ShouldQueue, ShouldBeUniqueUntilProcessing class RemoteStatusDelete implements ShouldQueue, ShouldBeUniqueUntilProcessing
{ {
@ -109,9 +109,7 @@ class RemoteStatusDelete implements ShouldQueue, ShouldBeUniqueUntilProcessing
} }
StatusService::del($status->id, true); StatusService::del($status->id, true);
AccountStatService::decrementPostCount($status->profile_id);
DecrementPostCount::dispatch($status->profile_id)->onQueue('inbox');
return $this->unlinkRemoveMedia($status); return $this->unlinkRemoveMedia($status);
} }

View file

@ -14,6 +14,11 @@ class AccountStatService
return Redis::zadd(self::REFRESH_CACHE_KEY, $pid, $pid); return Redis::zadd(self::REFRESH_CACHE_KEY, $pid, $pid);
} }
public static function decrementPostCount($pid)
{
return Redis::zadd(self::REFRESH_CACHE_KEY, $pid, $pid);
}
public static function removeFromPostCount($pid) public static function removeFromPostCount($pid)
{ {
return Redis::zrem(self::REFRESH_CACHE_KEY, $pid); return Redis::zrem(self::REFRESH_CACHE_KEY, $pid);

View file

@ -39,8 +39,6 @@ use App\Jobs\HomeFeedPipeline\FeedInsertRemotePipeline;
use App\Util\Media\License; use App\Util\Media\License;
use App\Models\Poll; use App\Models\Poll;
use Illuminate\Contracts\Cache\LockTimeoutException; use Illuminate\Contracts\Cache\LockTimeoutException;
use App\Jobs\ProfilePipeline\IncrementPostCount;
use App\Jobs\ProfilePipeline\DecrementPostCount;
use App\Services\DomainService; use App\Services\DomainService;
use App\Services\UserFilterService; use App\Services\UserFilterService;
use App\Services\Account\AccountStatService; use App\Services\Account\AccountStatService;

View file

@ -48,8 +48,6 @@ use App\Services\UserFilterService;
use App\Services\NetworkTimelineService; use App\Services\NetworkTimelineService;
use App\Models\Conversation; use App\Models\Conversation;
use App\Models\RemoteReport; use App\Models\RemoteReport;
use App\Jobs\ProfilePipeline\IncrementPostCount;
use App\Jobs\ProfilePipeline\DecrementPostCount;
use App\Jobs\HomeFeedPipeline\FeedRemoveRemotePipeline; use App\Jobs\HomeFeedPipeline\FeedRemoveRemotePipeline;
class Inbox class Inbox