mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-05-18 20:34:52 +00:00
308cd8a611
- Introduced `recalculateActivity` method in `Meetup` model to centralize activity and event timestamp updates. - Added `MeetupEventObserver` to trigger activity recalculation on event save/delete. - Updated `/meetups:update-activity` command to leverage the new model method for cleanup. - Enhanced tests to cover various `MeetupEvent` scenarios affecting activity states.
27 lines
696 B
PHP
27 lines
696 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Database;
|
|
|
|
use App\Models\Meetup;
|
|
use Illuminate\Console\Attributes\Description;
|
|
use Illuminate\Console\Attributes\Signature;
|
|
use Illuminate\Console\Command;
|
|
|
|
#[Signature('meetups:update-activity')]
|
|
#[Description('Recalculate is_active and last_event_at for every meetup based on its events.')]
|
|
class UpdateMeetupActivity extends Command
|
|
{
|
|
public function handle(): int
|
|
{
|
|
Meetup::query()->chunkById(200, function ($meetups) {
|
|
foreach ($meetups as $meetup) {
|
|
$meetup->recalculateActivity();
|
|
}
|
|
});
|
|
|
|
$this->info('Meetup activity flags updated.');
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|