Attendee Grid Fixes
Change-Id: I4e726692ab8a94a39057089edb2215c026fa4cf9 Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
a13099b368
commit
0cf0a3431d
90
app/Console/Commands/RecalculateAttendeesStatusCommand.php
Normal file
90
app/Console/Commands/RecalculateAttendeesStatusCommand.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* Copyright 2020 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 App\Services\Model\IAttendeeService;
|
||||
use Illuminate\Console\Command;
|
||||
use models\summit\ISummitRepository;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
/**
|
||||
* Class RecalculateAttendeesStatusCommand
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
class RecalculateAttendeesStatusCommand extends Command {
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'summit:recalculate-attendees-status';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'summit:recalculate-attendees-status {summit_id}';
|
||||
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Recalculate Attendees Status';
|
||||
|
||||
/**
|
||||
* @var ISummitRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var IAttendeeService
|
||||
*/
|
||||
private $service;
|
||||
|
||||
public function __construct(
|
||||
ISummitRepository $repository,
|
||||
IAttendeeService $service
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->repository = $repository;
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$start = time();
|
||||
$summit_id = $this->argument('summit_id');
|
||||
if(empty($summit_id))
|
||||
throw new \InvalidArgumentException("summit_id is required");
|
||||
$this->service->recalculateAttendeeStatus(intval($summit_id));
|
||||
$end = time();
|
||||
$delta = $end - $start;
|
||||
$this->info(sprintf("execution call %s seconds", $delta));
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -44,6 +44,7 @@ class Kernel extends ConsoleKernel
|
||||
\App\Console\Commands\SummitEmailFlowEventSeederCommand::class,
|
||||
\App\Console\Commands\SummitEmailFlowTypeSeederCommand::class,
|
||||
\App\Console\Commands\PresentationMaterialsCreateMUXAssetsCommand::class,
|
||||
\App\Console\Commands\RecalculateAttendeesStatusCommand::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ final class SummitAttendeeCSVSerializer extends SilverStripeSerializer
|
||||
'Email' => 'email:json_string',
|
||||
'CompanyName' => 'company:json_string',
|
||||
'DisclaimerAcceptedDate' => 'disclaimer_accepted_date:datetime_epoch',
|
||||
'Status' => 'status:json_string',
|
||||
];
|
||||
|
||||
|
||||
|
||||
}
|
@ -2034,6 +2034,9 @@ SQL;
|
||||
return $this->attendees->count();
|
||||
}
|
||||
|
||||
public function getAttendees(){
|
||||
return $this->attendees;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
|
@ -25,6 +25,7 @@ use models\summit\factories\SummitAttendeeFactory;
|
||||
use models\summit\ISummitAttendeeRepository;
|
||||
use models\summit\ISummitAttendeeTicketRepository;
|
||||
use models\summit\ISummitRegistrationPromoCodeRepository;
|
||||
use models\summit\ISummitRepository;
|
||||
use models\summit\ISummitTicketTypeRepository;
|
||||
use models\summit\Summit;
|
||||
use models\summit\SummitAttendee;
|
||||
@ -71,6 +72,11 @@ final class AttendeeService extends AbstractService implements IAttendeeService
|
||||
*/
|
||||
private $promo_code_repository;
|
||||
|
||||
/**
|
||||
* @var ISummitRepository
|
||||
*/
|
||||
private $summit_repository;
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
@ -79,6 +85,7 @@ final class AttendeeService extends AbstractService implements IAttendeeService
|
||||
ISummitAttendeeTicketRepository $ticket_repository,
|
||||
ISummitTicketTypeRepository $ticket_type_repository,
|
||||
ISummitRegistrationPromoCodeRepository $promo_code_repository,
|
||||
ISummitRepository $summit_repository,
|
||||
IEventbriteAPI $eventbrite_api,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
@ -90,6 +97,7 @@ final class AttendeeService extends AbstractService implements IAttendeeService
|
||||
$this->ticket_type_repository = $ticket_type_repository;
|
||||
$this->promo_code_repository = $promo_code_repository;
|
||||
$this->eventbrite_api = $eventbrite_api;
|
||||
$this->summit_repository = $summit_repository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -422,4 +430,15 @@ final class AttendeeService extends AbstractService implements IAttendeeService
|
||||
Log::warning($ex);
|
||||
}
|
||||
}
|
||||
|
||||
public function recalculateAttendeeStatus(int $summit_id):void{
|
||||
$this->tx_service->transaction(function() use($summit_id){
|
||||
$summit = $this->summit_repository->getById($summit_id);
|
||||
if(is_null($summit) || !$summit instanceof Summit) return;
|
||||
|
||||
foreach($summit->getAttendees() as $attendee){
|
||||
$attendee->updateStatus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -102,4 +102,9 @@ interface IAttendeeService
|
||||
* @param Filter|null $filter
|
||||
*/
|
||||
public function send(int $summit_id, array $payload, Filter $filter = null):void;
|
||||
|
||||
/**
|
||||
* @param int $summit_id
|
||||
*/
|
||||
public function recalculateAttendeeStatus(int $summit_id):void;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user