Update InstanceService, fix total post count when config_cache is disabled

pull/6177/head
Daniel Supernault 2 months ago
parent ab085452a7
commit f0bc9d66e4
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -4,7 +4,8 @@ namespace App\Services;
use App\Instance;
use App\Util\Blurhash\Blurhash;
use Cache;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class InstanceService
{
@ -100,7 +101,17 @@ class InstanceService
public static function totalLocalStatuses()
{
return config_cache('instance.stats.total_local_posts');
if (config('instance.enable_cc')) {
return config_cache('instance.stats.total_local_posts');
}
return Cache::remember(self::CACHE_KEY_TOTAL_POSTS, now()->addHour(), function () {
return DB::table('statuses')
->whereNull('deleted_at')
->where('local', true)
->whereNot('type', 'share')
->count();
});
}
public static function headerBlurhash()

Loading…
Cancel
Save