Browse Source

Merge pull request #6177 from pixelfed/staging

Update InstanceService, fix total post count when config_cache is dis…
dansup 1 tuần trước cách đây
mục cha
commit
cb0ab839ca
2 tập tin đã thay đổi với 14 bổ sung2 xóa
  1. 1 0
      CHANGELOG.md
  2. 13 2
      app/Services/InstanceService.php

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 
 - Update Status storage, add SanitizerService to fix spacing in html stripped content ([3686c9212](https://github.com/pixelfed/pixelfed/commit/3686c9212))
 - Update app config, add description and rule env variables ([0980519a9](https://github.com/pixelfed/pixelfed/commit/0980519a9))
+- Update InstanceService, fix total post count when config_cache is disabled ([f0bc9d66e](https://github.com/pixelfed/pixelfed/commit/f0bc9d66e))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.12.6 (2025-09-03)](https://github.com/pixelfed/pixelfed/compare/v0.12.6...dev)

+ 13 - 2
app/Services/InstanceService.php

@@ -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()