Serve dashboard stats from daily_stats and default visit list to today.

Stop live-scanning page_visits on every dashboard load (including today) so the admin home stays fast; keep the live path only for channel filters and cache the result for 45s.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
root
2026-10-11 09:46:38 +00:00
parent 11caef98fc
commit fcbc479c2e
9 changed files with 550 additions and 76 deletions
+6 -3
View File
@@ -12,6 +12,7 @@ use App\Models\WalletAddress;
use App\Models\WalletMnemonic;
use App\Services\DashboardStatsService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
@@ -163,7 +164,7 @@ class DailyReportTest extends TestCase
'channel_id' => self::CHANNEL,
'has_wallet' => Device::WALLET_YES,
]);
\Illuminate\Support\Facades\DB::table('devices')->where('id', $device->id)->update([
DB::table('devices')->where('id', $device->id)->update([
'created_at' => $yesterday->toDateTimeString(),
'updated_at' => $yesterday->toDateTimeString(),
]);
@@ -172,7 +173,7 @@ class DailyReportTest extends TestCase
'address' => 'THistDailyAddr1111111111111111111',
'chain_type' => 'TRON',
]);
\Illuminate\Support\Facades\DB::table('wallet_addresses')->where('id', $addr->id)->update([
DB::table('wallet_addresses')->where('id', $addr->id)->update([
'created_at' => $yesterday->toDateTimeString(),
'updated_at' => $yesterday->toDateTimeString(),
]);
@@ -182,7 +183,7 @@ class DailyReportTest extends TestCase
]);
$mnemonic->mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
$mnemonic->save();
\Illuminate\Support\Facades\DB::table('wallet_mnemonics')->where('id', $mnemonic->id)->update([
DB::table('wallet_mnemonics')->where('id', $mnemonic->id)->update([
'created_at' => $yesterday->toDateTimeString(),
'updated_at' => $yesterday->toDateTimeString(),
]);
@@ -198,6 +199,8 @@ class DailyReportTest extends TestCase
$this->assertNotNull($row);
$this->assertSame(1, $row->uv);
$this->assertSame(1, $row->effective_uv);
$this->assertSame(1, $row->pv);
$this->assertSame(1, $row->effective_pv);
$this->assertSame(1, $row->devices);
$this->assertSame(1, $row->wallet_devices);
$this->assertSame(1, $row->address_count);