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\Instance;
use App\Util\Blurhash\Blurhash; use App\Util\Blurhash\Blurhash;
use Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
class InstanceService class InstanceService
{ {
@ -100,9 +101,19 @@ class InstanceService
public static function totalLocalStatuses() public static function totalLocalStatuses()
{ {
if (config('instance.enable_cc')) {
return config_cache('instance.stats.total_local_posts'); 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() public static function headerBlurhash()
{ {
return Cache::rememberForever(self::CACHE_KEY_BANNER_BLURHASH, function () { return Cache::rememberForever(self::CACHE_KEY_BANNER_BLURHASH, function () {

Loading…
Cancel
Save