mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Fix user count
This commit is contained in:
@@ -100,7 +100,7 @@ class AdminDashboardSnapshotService
|
||||
// Approximate counts on huge tables — InnoDB metadata estimates are
|
||||
// good enough for the admin overview tiles.
|
||||
$releasesCount = ApproximateRowCount::for('releases');
|
||||
$usersCount = ApproximateRowCount::for('users');
|
||||
$usersApproximateCount = ApproximateRowCount::for('users');
|
||||
$groupsCount = ApproximateRowCount::for('usenet_groups');
|
||||
$failedCount = ApproximateRowCount::for('dnzb_failures');
|
||||
|
||||
@@ -108,6 +108,7 @@ class AdminDashboardSnapshotService
|
||||
$activeGroupsCount = UsenetGroup::where('active', 1)->count();
|
||||
$reportedCount = ReleaseReport::where('status', 'pending')->count();
|
||||
$softDeletedCount = User::onlyTrashed()->count();
|
||||
$activeUsersCount = max($usersApproximateCount - $softDeletedCount, 0);
|
||||
|
||||
// Replaces previous whereJsonContains() count which couldn't use an index.
|
||||
$permanentlyDeletedCount = UserActivity::query()
|
||||
@@ -121,7 +122,7 @@ class AdminDashboardSnapshotService
|
||||
return [
|
||||
'releases' => $releasesCount,
|
||||
'releases_today' => $releasesToday,
|
||||
'users' => $usersCount,
|
||||
'users' => $activeUsersCount,
|
||||
'users_today' => $usersToday,
|
||||
'groups' => $groupsCount,
|
||||
'active_groups' => $activeGroupsCount,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminDashboardUserCountTest extends TestCase
|
||||
{
|
||||
public function test_dashboard_snapshot_excludes_soft_deleted_users_from_active_count(): void
|
||||
{
|
||||
$servicePath = app_path('Services/AdminDashboardSnapshotService.php');
|
||||
|
||||
$this->assertFileExists($servicePath);
|
||||
|
||||
$content = (string) file_get_contents($servicePath);
|
||||
|
||||
$this->assertStringContainsString('$usersApproximateCount = ApproximateRowCount::for(\'users\');', $content);
|
||||
$this->assertStringContainsString('$softDeletedCount = User::onlyTrashed()->count();', $content);
|
||||
$this->assertStringContainsString('$activeUsersCount = max($usersApproximateCount - $softDeletedCount, 0);', $content);
|
||||
$this->assertStringContainsString("'users' => \$activeUsersCount", $content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user