Merge pull request #4895 from pixelfed/staging

Update AP helpers, refactor post count decrement logic
pull/4917/head
daniel 2024-02-04 03:03:16 -07:00 zatwierdzone przez GitHub
commit 2483832754
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
8 zmienionych plików z 15 dodań i 72 usunięć

Wyświetl plik

@ -94,6 +94,7 @@
- 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))
- Update AP helpers, refactor post count decrement logic ([b81ae577](https://github.com/pixelfed/pixelfed/commit/b81ae577))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)

Wyświetl plik

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

Wyświetl plik

@ -35,18 +35,7 @@ class DecrementPostCount implements ShouldQueue
*/
public function handle()
{
$id = $this->id;
$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;
// deprecated
return;
}
}

Wyświetl plik

@ -14,42 +14,12 @@ use App\Profile;
use App\Status;
use App\Services\AccountService;
class IncrementPostCount implements ShouldQueue, ShouldBeUniqueUntilProcessing
class IncrementPostCount implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
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.
*
@ -67,20 +37,7 @@ class IncrementPostCount implements ShouldQueue, ShouldBeUniqueUntilProcessing
*/
public function handle()
{
$id = $this->id;
$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;
// deprecated
return;
}
}

Wyświetl plik

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

Wyświetl plik

@ -14,6 +14,11 @@ class AccountStatService
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)
{
return Redis::zrem(self::REFRESH_CACHE_KEY, $pid);

Wyświetl plik

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

Wyświetl plik

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