Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117910241
D5181.1775396575.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D5181.1775396575.diff
View Options
diff --git a/src/app/Http/Controllers/API/V4/MetricsController.php b/src/app/Http/Controllers/API/V4/MetricsController.php
--- a/src/app/Http/Controllers/API/V4/MetricsController.php
+++ b/src/app/Http/Controllers/API/V4/MetricsController.php
@@ -28,10 +28,12 @@
*/
protected function collectPayersCount(): int
{
- // A subquery to get the all wallets with a successful payment
- $payments = DB::table('payments')
- ->selectRaw('distinct wallet_id')
- ->where('status', Payment::STATUS_PAID);
+ // A subquery to get the all wallets with a credit/award transaction
+ $transactions = DB::table('transactions')
+ ->selectRaw('distinct object_id as wallet_id')
+ ->where('object_type', Wallet::class)
+ ->where('amount', '>', 0)
+ ->whereIn('type', [Transaction::WALLET_AWARD, Transaction::WALLET_CREDIT]);
// A subquery to get users' wallets (by entitlement) - one record per user
$wallets = DB::table('entitlements')
@@ -44,8 +46,8 @@
->joinSub($wallets, 'wallets', function ($join) {
$join->on('users.id', '=', 'wallets.user_id');
})
- ->joinSub($payments, 'payments', function ($join) {
- $join->on('wallets.id', '=', 'payments.wallet_id');
+ ->joinSub($transactions, 'transactions', function ($join) {
+ $join->on('wallets.id', '=', 'transactions.wallet_id');
})
->whereNull('users.deleted_at')
->whereNot('users.status', '&', User::STATUS_DEGRADED | User::STATUS_SUSPENDED);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 1:42 PM (1 d, 7 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18833573
Default Alt Text
D5181.1775396575.diff (1 KB)
Attached To
Mode
D5181: Metrics: Improve collectPayersCount() - use transactions instead of payments
Attached
Detach File
Event Timeline