Added missing seeding commands

Change-Id: Iae3f0fde9930b05aa95a2af71b834815a0eab01a
Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
smarcet 2020-09-25 14:14:40 -03:00
parent c14491545c
commit 9808c8a8db
5 changed files with 142 additions and 2 deletions

View File

@ -0,0 +1,64 @@
<?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 Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
/**
* Class SummitEmailFlowEventSeederCommand
* @package App\Console\Commands
*/
class SummitEmailFlowEventSeederCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'summit:seed-email-flow-events';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'summit:seed-email-flow-events';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Seed Email Flow Event on Summits';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
try {
$start = time();
\SummitEmailFlowEventSeeder::seed();
$end = time();
$delta = $end - $start;
$this->info(sprintf("execution call %s seconds", $delta));
}
catch (Exception $ex) {
Log::error($ex);
}
}
}

View File

@ -0,0 +1,65 @@
<?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 Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use Exception;
/**
* Class SummitEmailFlowTypeSeederCommand
* @package App\Console\Commands
*/
class SummitEmailFlowTypeSeederCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'summit:seed-email-flow-types';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'summit:seed-email-flow-types';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Seed Email Flow Types';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
try {
$start = time();
\SummitEmailFlowTypeSeeder::seed();
$end = time();
$delta = $end - $start;
$this->info(sprintf("execution call %s seconds", $delta));
}
catch (Exception $ex) {
Log::error($ex);
}
}
}

View File

@ -39,6 +39,8 @@ class Kernel extends ConsoleKernel
\App\Console\Commands\RegistrationSummitOrderRevocationCommand::class,
\App\Console\Commands\RegistrationSummitOrderReminderEmailCommand::class,
\App\Console\Commands\SummitForwardXDays::class,
\App\Console\Commands\SummitEmailFlowEventSeederCommand::class,
\App\Console\Commands\SummitEmailFlowTypeSeederCommand::class,
];
/**

View File

@ -22,6 +22,10 @@ final class SummitEmailFlowEventSeeder extends Seeder
{
public function run()
{
self::seed();
}
public static function seed(){
$em = Registry::getManager(SilverstripeBaseModel::EntityManager);
$summit_repository = $em->getRepository(Summit::class);
foreach ($summit_repository->findAll() as $summit) {

View File

@ -63,13 +63,19 @@ final class SummitEmailFlowTypeSeeder extends Seeder
{
public function run()
{
$em = Registry::getManager(SilverstripeBaseModel::EntityManager);
DB::setDefaultConnection("model");
DB::table("SummitEmailFlowType")->delete();
DB::table("SummitEmailEventFlowType")->delete();
DB::table("SummitEmailEventFlow")->delete();
self::seed();
}
public static function seed(){
$em = Registry::getManager(SilverstripeBaseModel::EntityManager);
$flow = new SummitEmailFlowType();
$flow->setName("Registration");
@ -283,7 +289,6 @@ final class SummitEmailFlowTypeSeeder extends Seeder
$em->persist($flow);
$em->flush();
}
/**
* @param array $payload
* @param SummitEmailFlowType $flow