Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117912803
D4749.1775400496.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
D4749.1775400496.diff
View Options
diff --git a/src/app/Console/Commands/Data/ImportCommand.php b/src/app/Console/Commands/Data/ImportCommand.php
--- a/src/app/Console/Commands/Data/ImportCommand.php
+++ b/src/app/Console/Commands/Data/ImportCommand.php
@@ -28,10 +28,10 @@
public function handle()
{
$commands = [
- #Import\CountriesCommand::class,
+ Import\CountriesCommand::class,
Import\OpenExchangeRatesCommand::class,
- #Import\IP4NetsCommand::class,
- #Import\IP6NetsCommand::class
+ Import\IP4NetsCommand::class,
+ Import\IP6NetsCommand::class
];
foreach ($commands as $command) {
diff --git a/src/app/Console/Commands/Data/Stats/CollectorCommand.php b/src/app/Console/Commands/Data/Stats/CollectorCommand.php
--- a/src/app/Console/Commands/Data/Stats/CollectorCommand.php
+++ b/src/app/Console/Commands/Data/Stats/CollectorCommand.php
@@ -22,7 +22,7 @@
*
* @var string
*/
- protected $description = 'Collects statictical data about the system (for charts)';
+ protected $description = 'Collects statistical data about the system (for charts)';
/**
* Execute the console command.
@@ -39,8 +39,6 @@
*/
protected function collectPayersCount(): void
{
- $tenant_id = \config('app.tenant_id');
-
// A subquery to get the all wallets with a successful payment
$payments = DB::table('payments')
->selectRaw('distinct wallet_id')
@@ -53,7 +51,8 @@
->groupBy('entitleable_id');
// Count all non-degraded and non-deleted users with any successful payment
- $count = DB::table('users')
+ $counts = DB::table('users')
+ ->selectRaw('count(*) as total, users.tenant_id')
->joinSub($wallets, 'wallets', function ($join) {
$join->on('users.id', '=', 'wallets.user_id');
})
@@ -62,22 +61,16 @@
})
->whereNull('users.deleted_at')
->whereNot('users.status', '&', User::STATUS_DEGRADED)
- ->whereNot('users.status', '&', User::STATUS_SUSPENDED);
-
- if ($tenant_id) {
- $count->where('users.tenant_id', $tenant_id);
- } else {
- $count->whereNull('users.tenant_id');
- }
-
- $count = $count->count();
-
- if ($count) {
- DB::table('stats')->insert([
- 'tenant_id' => $tenant_id,
+ ->whereNot('users.status', '&', User::STATUS_SUSPENDED)
+ ->groupBy('users.tenant_id')
+ ->havingRaw('count(*) > 0')
+ ->get()
+ ->each(function ($record) {
+ DB::table('stats')->insert([
+ 'tenant_id' => $record->tenant_id,
'type' => StatsController::TYPE_PAYERS,
- 'value' => $count,
- ]);
- }
+ 'value' => $record->total,
+ ]);
+ });
}
}
diff --git a/src/app/Console/Commands/PasswordRetentionCommand.php b/src/app/Console/Commands/PasswordRetentionCommand.php
--- a/src/app/Console/Commands/PasswordRetentionCommand.php
+++ b/src/app/Console/Commands/PasswordRetentionCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands;
use App\Console\Command;
+use App\User;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
@@ -30,9 +31,8 @@
public function handle()
{
// Get all users (accounts) with max_password_age set
- $accounts = \App\User::select('users.*', 'user_settings.value as max_age')
+ $accounts = User::select('users.*', 'user_settings.value as max_age')
->join('user_settings', 'users.id', '=', 'user_settings.user_id')
- ->withEnvTenantContext('users')
->where('user_settings.key', 'max_password_age')
->cursor();
@@ -46,6 +46,7 @@
)
->get()
->each(function ($user) use ($account) {
+ /** @var User $user */
// Skip incomplete or suspended users
if (!$user->isImapReady() || $user->isSuspended()) {
return;
@@ -58,6 +59,7 @@
$lastUpdate = $user->created_at;
}
+ // @phpstan-ignore-next-line
$nextUpdate = $lastUpdate->copy()->addMonthsWithoutOverflow($account->max_age);
$diff = Carbon::now()->diffInDays($nextUpdate, false);
diff --git a/src/app/Console/Commands/Wallet/ChargeCommand.php b/src/app/Console/Commands/Wallet/ChargeCommand.php
--- a/src/app/Console/Commands/Wallet/ChargeCommand.php
+++ b/src/app/Console/Commands/Wallet/ChargeCommand.php
@@ -46,7 +46,6 @@
// Get all wallets, excluding deleted accounts
$wallets = \App\Wallet::select('wallets.id')
->join('users', 'users.id', '=', 'wallets.user_id')
- ->withEnvTenantContext('users')
->whereNull('users.deleted_at')
->cursor();
}
diff --git a/src/app/Console/Commands/Wallet/TrialEndCommand.php b/src/app/Console/Commands/Wallet/TrialEndCommand.php
--- a/src/app/Console/Commands/Wallet/TrialEndCommand.php
+++ b/src/app/Console/Commands/Wallet/TrialEndCommand.php
@@ -30,7 +30,6 @@
// Get all wallets...
$wallets = \App\Wallet::select('wallets.*')
->join('users', 'users.id', '=', 'wallets.user_id')
- ->withEnvTenantContext('users')
// exclude deleted accounts
->whereNull('users.deleted_at')
// exclude "inactive" accounts
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 2:48 PM (17 m, 48 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18833693
Default Alt Text
D4749.1775400496.diff (5 KB)
Attached To
Mode
D4749: Make scheduled commands to work for all tenants (not the configured one)
Attached
Detach File
Event Timeline