Use laravel task scheduler

This commit is contained in:
2026-05-26 15:17:57 +02:00
parent 5dc1bff60c
commit 81639aaabf
3 changed files with 15 additions and 6 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ class GenerateSitemap extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'sitemap:generate'; protected $signature = 'app:generate-sitemap';
/** /**
* The console command description. * The console command description.
@@ -8,6 +8,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Log;
class SyncSubscriptionKeys extends Command class SyncSubscriptionKeys extends Command
{ {
@@ -83,7 +84,10 @@ class SyncSubscriptionKeys extends Command
->whereNotIn('subscription_key', $activeKeys) ->whereNotIn('subscription_key', $activeKeys)
->chunk(100, function ($users) { ->chunk(100, function ($users) {
foreach($users as $user) { foreach($users as $user) {
$user->removeRole(UserRole::SUPPORTER); if ($user->hasRole(UserRole::SUPPORTER)) {
Log::info("Removed Supporter Role from {$user->name}");
$user->removeRole(UserRole::SUPPORTER);
}
} }
}); });
} }
@@ -95,7 +99,10 @@ class SyncSubscriptionKeys extends Command
->whereIn('subscription_key', $activeKeys) ->whereIn('subscription_key', $activeKeys)
->chunk(100, function ($users) { ->chunk(100, function ($users) {
foreach($users as $user) { foreach($users as $user) {
$user->addRole(UserRole::SUPPORTER); if (!$user->hasRole(UserRole::SUPPORTER)) {
Log::info("Added Supporter Role for {$user->name}");
$user->addRole(UserRole::SUPPORTER);
}
} }
}); });
} }
+5 -3
View File
@@ -2,6 +2,7 @@
use Illuminate\Foundation\Inspiring; use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -14,6 +15,7 @@ use Illuminate\Support\Facades\Artisan;
| |
*/ */
Artisan::command('inspire', function () { Schedule::command('app:auto-stats')->hourly();
$this->comment(Inspiring::quote()); Schedule::command('app:reset-user-downloads')->daily();
})->purpose('Display an inspiring quote'); Schedule::command('app:generate-sitemap')->daily();
Schedule::command('app:sync-subscription-keys')->daily();