perf(admin): platform orders list read batch_activation first
This commit is contained in:
@@ -105,6 +105,26 @@ class PlatformOrderController extends Controller
|
||||
->count(),
|
||||
'total_payable_amount' => (float) ((clone $baseQuery)->sum('payable_amount') ?: 0),
|
||||
'total_paid_amount' => (float) ((clone $baseQuery)->sum('paid_amount') ?: 0),
|
||||
'syncable_orders' => (clone $baseQuery)
|
||||
->where('payment_status', 'paid')
|
||||
->where('status', 'activated')
|
||||
->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation.subscription_id') IS NULL")
|
||||
->count(),
|
||||
'batch_synced_24h_orders' => (function () use ($baseQuery) {
|
||||
$since = now()->subHours(24)->format('Y-m-d H:i:s');
|
||||
|
||||
$q = (clone $baseQuery)
|
||||
->whereRaw("JSON_EXTRACT(meta, '$.batch_activation.at') IS NOT NULL");
|
||||
|
||||
$driver = $q->getQuery()->getConnection()->getDriverName();
|
||||
if ($driver === 'sqlite') {
|
||||
$q->whereRaw("JSON_EXTRACT(meta, '$.batch_activation.at') >= ?", [$since]);
|
||||
} else {
|
||||
$q->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(meta, '$.batch_activation.at')) >= ?", [$since]);
|
||||
}
|
||||
|
||||
return $q->count();
|
||||
})(),
|
||||
],
|
||||
'failedReasonStats' => $failedReasonStats,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user