Fixed Presentation Actions Synch

Change-Id: Iccfad6794315e83867cb2e2bbb240349a649c58a
Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
smarcet 2021-04-28 11:41:18 -03:00
parent 1e66d9688b
commit 0ef84316f0
6 changed files with 180 additions and 1 deletions

View File

@ -0,0 +1,95 @@
<?php namespace App\Console\Commands;
/**
* Copyright 2021 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use libs\utils\ICacheService;
use models\summit\ISummitRepository;
use services\model\ISummitService;
/**
* Class SummitSyncAllPresentationActions
* @package App\Console\Commands
*/
class SummitSyncAllPresentationActions extends Command {
/**
* @var ISummitService
*/
private $service;
/**
* @var ISummitRepository
*/
private $repository;
/**
* @var ICacheService
*/
private $cache_service;
/**
* SummitSyncAllPresentationActions constructor.
* @param ISummitRepository $repository
* @param ISummitService $service
* @param ICacheService $cache_service
*/
public function __construct(
ISummitRepository $repository,
ISummitService $service,
ICacheService $cache_service
)
{
parent::__construct();
$this->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()));
}
}
}

View File

@ -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();

View File

@ -24,7 +24,7 @@ use models\summit\ISummitRepository;
* Class SynchAllPresentationActions
* @package App\Jobs
*/
class SynchAllPresentationActions implements ShouldQueue
class SynchAllPresentationActions implements ShouldQueue
{
public $tries = 2;

View File

@ -0,0 +1,70 @@
<?php namespace App\Jobs;
/**
* Copyright 2021 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use libs\utils\ITransactionService;
use models\exceptions\EntityNotFoundException;
use models\summit\ISummitEventRepository;
use models\summit\ISummitRepository;
use models\summit\Presentation;
/**
* Class SynchPresentationActions
* @package App\Jobs
*/
class SynchPresentationActions implements ShouldQueue
{
public $tries = 2;
public $timeout = PHP_INT_MAX;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* @var int
*/
private $event_id;
/**
* SynchAllPresentationActions constructor.
* @param int $event_id
*/
public function __construct(int $event_id)
{
$this->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();
});
}
}

View File

@ -5260,4 +5260,8 @@ SQL;
$presentation->initializeActions();
}
}
public function synchPresentationAction(Presentation $presentation):void{
$presentation->initializeActions();
}
}

View File

@ -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)