Merge pull request #5902 from intentionally-left-nil/fix-local-stats

[Bug Fix] Fix server post stats
pull/5922/head
daniel 3 months ago committed by GitHub
commit b7ae725850
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -53,9 +53,8 @@ class InstanceUpdateTotalLocalPosts extends Command
protected function initCache() protected function initCache()
{ {
$count = DB::table('statuses')->whereNull(['url', 'deleted_at'])->count();
$res = [ $res = [
'count' => $count, 'count' => $this->getTotalLocalPosts(),
]; ];
Storage::put('total_local_posts.json', json_encode($res, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); Storage::put('total_local_posts.json', json_encode($res, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
ConfigCacheService::put('instance.stats.total_local_posts', $res['count']); ConfigCacheService::put('instance.stats.total_local_posts', $res['count']);
@ -68,12 +67,20 @@ class InstanceUpdateTotalLocalPosts extends Command
protected function updateAndCache() protected function updateAndCache()
{ {
$count = DB::table('statuses')->whereNull(['url', 'deleted_at'])->count();
$res = [ $res = [
'count' => $count, 'count' => $this->getTotalLocalPosts(),
]; ];
Storage::put('total_local_posts.json', json_encode($res, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); Storage::put('total_local_posts.json', json_encode($res, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
ConfigCacheService::put('instance.stats.total_local_posts', $res['count']); ConfigCacheService::put('instance.stats.total_local_posts', $res['count']);
} }
protected function getTotalLocalPosts()
{
return DB::table('statuses')
->whereNull('deleted_at')
->where('local', true)
->whereNot('type', 'share') # Ignore boosts for the post count
->count();
}
} }

Loading…
Cancel
Save