kopia lustrzana https://github.com/pixelfed/pixelfed
commit
8e619cca22
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\AccountService;
|
||||
use App\Services\Account\AccountStatService;
|
||||
use App\Status;
|
||||
use App\Profile;
|
||||
use App\Services\Account\AccountStatService;
|
||||
use App\Services\AccountService;
|
||||
use App\Status;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AccountPostCountStatUpdate extends Command
|
||||
{
|
||||
|
|
@ -29,29 +29,53 @@ class AccountPostCountStatUpdate extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$ids = AccountStatService::getAllPostCountIncr();
|
||||
if(!$ids || !count($ids)) {
|
||||
$chunkSize = 100;
|
||||
$lastId = 0;
|
||||
|
||||
while (true) {
|
||||
$ids = AccountStatService::getPostCountChunk($lastId, $chunkSize);
|
||||
|
||||
if (empty($ids)) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$this->processAccount($id);
|
||||
$lastId = $id;
|
||||
}
|
||||
|
||||
if (function_exists('gc_collect_cycles')) {
|
||||
gc_collect_cycles();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function processAccount($id)
|
||||
{
|
||||
$acct = AccountService::get($id, true);
|
||||
if (! $acct) {
|
||||
AccountStatService::removeFromPostCount($id);
|
||||
|
||||
return;
|
||||
}
|
||||
foreach($ids as $id) {
|
||||
$acct = AccountService::get($id, true);
|
||||
if(!$acct) {
|
||||
AccountStatService::removeFromPostCount($id);
|
||||
continue;
|
||||
}
|
||||
|
||||
$statusCount = Status::whereProfileId($id)->count();
|
||||
if($statusCount != $acct['statuses_count']) {
|
||||
if ($statusCount != $acct['statuses_count']) {
|
||||
$profile = Profile::find($id);
|
||||
if(!$profile) {
|
||||
if (! $profile) {
|
||||
AccountStatService::removeFromPostCount($id);
|
||||
continue;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$profile->status_count = $statusCount;
|
||||
$profile->save();
|
||||
|
||||
AccountService::del($id);
|
||||
}
|
||||
|
||||
AccountStatService::removeFromPostCount($id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,14 @@ class AccountStatService
|
|||
{
|
||||
return Redis::zrange(self::REFRESH_CACHE_KEY, 0, $limit);
|
||||
}
|
||||
|
||||
public static function getPostCountChunk($lastId, $count)
|
||||
{
|
||||
return Redis::zrangebyscore(
|
||||
self::REFRESH_CACHE_KEY,
|
||||
'(' . $lastId,
|
||||
'+inf',
|
||||
['limit' => [0, $count]]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,12 +137,12 @@ return [
|
|||
'notifications' => [
|
||||
|
||||
'notifications' => [
|
||||
\Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => ['mail'],
|
||||
\Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFoundNotification::class => ['mail'],
|
||||
\Spatie\Backup\Notifications\Notifications\CleanupHasFailedNotification::class => ['mail'],
|
||||
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => ['mail'],
|
||||
\Spatie\Backup\Notifications\Notifications\HealthyBackupWasFoundNotification::class => ['mail'],
|
||||
\Spatie\Backup\Notifications\Notifications\CleanupWasSuccessfulNotification::class => ['mail'],
|
||||
\Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => [],
|
||||
\Spatie\Backup\Notifications\Notifications\UnhealthyBackupWasFoundNotification::class => [],
|
||||
\Spatie\Backup\Notifications\Notifications\CleanupHasFailedNotification::class => [],
|
||||
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => [],
|
||||
\Spatie\Backup\Notifications\Notifications\HealthyBackupWasFoundNotification::class => [],
|
||||
\Spatie\Backup\Notifications\Notifications\CleanupWasSuccessfulNotification::class => [],
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ return [
|
|||
'profile' => 'Perfil',
|
||||
'drive' => 'Drive',
|
||||
'settings' => 'Definições',
|
||||
'appearance' => 'Aparência',
|
||||
'compose' => 'Criar novo',
|
||||
'logout' => 'Terminar Sessão',
|
||||
|
||||
|
|
@ -204,5 +205,18 @@ return [
|
|||
'thanksMsg' => 'Obrigado pela denúncia, pessoas como você ajudam a manter a nossa comunidade segura!',
|
||||
'contactAdminMsg' => 'Se quiser entrar em contato com um administrador acerca desta publicação ou denúncia',
|
||||
],
|
||||
'appearance' => [
|
||||
'theme' => 'Tema',
|
||||
'profileLayout' => 'Layout do Perfil',
|
||||
'compactPreviews' => 'Pré-visualizações Compactas',
|
||||
'loadComments' => 'Carregar Comentários',
|
||||
'hideStats' => 'Ocultar Contagens e Estatísticas',
|
||||
'auto' => 'Automático',
|
||||
'lightMode' => 'Modo Claro',
|
||||
'darkMode' => 'Modo Escuro',
|
||||
'grid' => 'Grade',
|
||||
'masonry' => 'Mansory',
|
||||
'feed' => 'Feed'
|
||||
]
|
||||
|
||||
];
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue