Merge remote-tracking branch 'gitea/main' into worktree-jivo-bot-core
This commit is contained in:
@@ -131,8 +131,8 @@ class AdminVisitorsController extends Controller
|
||||
->join('tenants as t', 't.id', '=', 'v.tenant_id')
|
||||
->whereBetween('v.last_seen_at', [$from, $to])
|
||||
->whereNotNull('v.tenant_id')
|
||||
->groupBy('t.id', 't.name', 't.subdomain')
|
||||
->select(['t.name', 't.subdomain', DB::raw('MAX(v.last_seen_at) AS last_seen_at')])
|
||||
->groupBy('t.id', 't.organization_name', 't.subdomain')
|
||||
->select(['t.organization_name as name', 't.subdomain', DB::raw('MAX(v.last_seen_at) AS last_seen_at')])
|
||||
->orderByDesc('last_seen_at')
|
||||
->limit(50)
|
||||
->get();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -85,3 +86,24 @@ test('пустой период — нули, а не ошибка', function ()
|
||||
$r->assertStatus(200);
|
||||
expect($r->json('funnel.view'))->toBe(0);
|
||||
});
|
||||
|
||||
test('активность в кабинете: экраны и клиенты, привязанные к гостю', function () {
|
||||
$tenant = Tenant::factory()->create(['organization_name' => 'ООО Ромашка']);
|
||||
|
||||
$id = visitor('sms', true, ['view', 'alive', 'login_done']);
|
||||
DB::table('site_visitors')->where('id', $id)->update(['tenant_id' => $tenant->id]);
|
||||
DB::table('site_events')->insert([
|
||||
['visitor_id' => $id, 'event' => 'portal_screen', 'screen' => '/deals', 'occurred_at' => now(), 'meta' => '{}'],
|
||||
['visitor_id' => $id, 'event' => 'portal_screen', 'screen' => '/deals', 'occurred_at' => now(), 'meta' => '{}'],
|
||||
['visitor_id' => $id, 'event' => 'portal_screen', 'screen' => '/billing', 'occurred_at' => now(), 'meta' => '{}'],
|
||||
]);
|
||||
|
||||
$r = $this->getJson('/api/admin/visitors/portal?period=7d');
|
||||
$r->assertStatus(200);
|
||||
|
||||
$deals = collect($r->json('screens'))->firstWhere('screen', '/deals');
|
||||
expect($deals['opens'])->toBe(2);
|
||||
expect($deals['people'])->toBe(1);
|
||||
|
||||
expect(collect($r->json('clients'))->pluck('name'))->toContain('ООО Ромашка');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user