diff --git a/app/Console/Commands/SummitSyncAllPresentationActions.php b/app/Console/Commands/SummitSyncAllPresentationActions.php new file mode 100644 index 00000000..47b872bc --- /dev/null +++ b/app/Console/Commands/SummitSyncAllPresentationActions.php @@ -0,0 +1,95 @@ +repository = $repository; + $this->service = $service; + $this->cache_service = $cache_service; + } + + /** + * The console command name. + * + * @var string + */ + protected $name = 'summit:synch-presentation-actions'; + + /** + * The name and signature of the console command. + * + * @var string + */ + protected $signature = 'summit:synch-presentation-actions'; + + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Synch All Summits Presention Actions'; + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $summits = $this->repository->getCurrentAndFutureSummits(); + foreach($summits as $summit) { + Log::debug(sprintf("SummitSyncAllPresentationActions::handle processing summit %s (%s)", $summit->getName(), $summit->getId())); + $this->info(sprintf("processing summit %s (%s)", $summit->getName(), $summit->getId())); + $summit->synchAllPresentationActions(); + $this->info(sprintf("regenerated presentation actions for summit id %s", $summit->getIdentifier())); + } + } + +} \ No newline at end of file diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 75cf99ea..b02bc71d 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,6 +13,7 @@ **/ use App\Console\Commands\PresentationMaterialsCreateMUXAssetsCommand; +use App\Console\Commands\SummitSyncAllPresentationActions; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Support\Facades\App; @@ -46,6 +47,7 @@ class Kernel extends ConsoleKernel \App\Console\Commands\PresentationMaterialsCreateMUXAssetsCommand::class, \App\Console\Commands\RecalculateAttendeesStatusCommand::class, \App\Console\Commands\EnableMP4SupportAtMUXCommand::class, + \App\Console\Commands\SummitSyncAllPresentationActions::class, ]; /** @@ -60,8 +62,12 @@ class Kernel extends ConsoleKernel $env = App::environment(); + // summit json cache $schedule->command('summit:json-generator')->everyFiveMinutes()->withoutOverlapping()->onOneServer(); + // synch presentation actions + $schedule->command('summit:synch-presentation-actions')->everyFiveMinutes()->withoutOverlapping()->onOneServer(); + // list of available summits $schedule->command('summit-list:json-generator')->everyFiveMinutes()->withoutOverlapping()->onOneServer(); diff --git a/app/Jobs/SynchAllPresentationActions.php b/app/Jobs/SynchAllPresentationActions.php index 422d2aa2..a82dca2e 100644 --- a/app/Jobs/SynchAllPresentationActions.php +++ b/app/Jobs/SynchAllPresentationActions.php @@ -24,7 +24,7 @@ use models\summit\ISummitRepository; * Class SynchAllPresentationActions * @package App\Jobs */ -class SynchAllPresentationActions implements ShouldQueue +class SynchAllPresentationActions implements ShouldQueue { public $tries = 2; diff --git a/app/Jobs/SynchPresentationActions.php b/app/Jobs/SynchPresentationActions.php new file mode 100644 index 00000000..7b02147e --- /dev/null +++ b/app/Jobs/SynchPresentationActions.php @@ -0,0 +1,70 @@ +event_id = $event_id; + } + + /** + * @param ISummitRepository $repository + * @param ITransactionService $tx_service + * @throws \Exception + */ + public function handle( + ISummitEventRepository $repository, + ITransactionService $tx_service + ) + { + Log::debug(sprintf("SynchPresentationActions::handle event id %s", $this->event_id)); + $tx_service->transaction(function() use($repository){ + $event = $repository->getById($this->event_id); + if(is_null($event) || !$event instanceof Presentation) + throw new EntityNotFoundException(sprintf("Event %s is not a presentation", $this->event_id)); + + $event->getSummit()->synchAllPresentationActions(); + }); + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Summit.php b/app/Models/Foundation/Summit/Summit.php index 6404ec52..2a563d73 100644 --- a/app/Models/Foundation/Summit/Summit.php +++ b/app/Models/Foundation/Summit/Summit.php @@ -5260,4 +5260,8 @@ SQL; $presentation->initializeActions(); } } + + public function synchPresentationAction(Presentation $presentation):void{ + $presentation->initializeActions(); + } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index e829845a..3d77401e 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -68,6 +68,7 @@ use App\Jobs\Emails\BookableRooms\BookableRoomReservationCanceledEmail; use App\Jobs\Emails\Schedule\RSVPRegularSeatMail; use App\Jobs\Emails\Schedule\RSVPWaitListSeatMail; use App\Jobs\SynchAllPresentationActions; +use App\Jobs\SynchPresentationActions; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Event; @@ -136,6 +137,9 @@ final class EventServiceProvider extends ServiceProvider Event::listen(\App\Events\SummitEventCreated::class, function($event) { EntityEventPersister::persist(SummitEventCreatedEntityEventFactory::build($event)); + + SynchPresentationActions::dispatch($event->getSummitEvent()->getId()); + }); Event::listen(\App\Events\SummitEventUpdated::class, function($event)