Added flag to enable/disable cal sync tasks

Change-Id: Iec6d6cb0dad9b8af6ba39a9ea4329a2ebe657543
This commit is contained in:
smarcet 2019-08-05 10:47:09 -03:00
parent dc19042816
commit 9df411a77f
4 changed files with 35 additions and 1 deletions

View File

@ -76,4 +76,6 @@ CLOUD_STORAGE_AUTH_URL=
CLOUD_STORAGE_USERNAME= CLOUD_STORAGE_USERNAME=
CLOUD_STORAGE_APIKEY= CLOUD_STORAGE_APIKEY=
CLOUD_STORAGE_PROJECT_NAME= CLOUD_STORAGE_PROJECT_NAME=
CLOUD_STORAGE_REGION= CLOUD_STORAGE_REGION=
# enable/disable cal sync background task
ENABLE_CAL_SYNC=true

View File

@ -13,6 +13,8 @@
**/ **/
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Services\Model\IAdminActionsCalendarSyncProcessingService; use App\Services\Model\IAdminActionsCalendarSyncProcessingService;
use Illuminate\Support\Facades\Config;
/** /**
* Class AdminActionsCalendarSyncProcessingCommand * Class AdminActionsCalendarSyncProcessingCommand
* @package App\Console\Commands * @package App\Console\Commands
@ -57,6 +59,12 @@ final class AdminActionsCalendarSyncProcessingCommand extends Command
public function handle() public function handle()
{ {
$enabled = boolval(Config::get("cal_sync.enable_cal_sync", true));
if(!$enabled){
$this->info("task is not enabled!");
return false;
}
$batch_size = $this->argument('batch_size'); $batch_size = $this->argument('batch_size');
if(empty($batch_size)) if(empty($batch_size))
$batch_size = PHP_INT_MAX; $batch_size = PHP_INT_MAX;

View File

@ -13,6 +13,7 @@
**/ **/
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Services\Model\IMemberActionsCalendarSyncProcessingService; use App\Services\Model\IMemberActionsCalendarSyncProcessingService;
use Illuminate\Support\Facades\Config;
use models\summit\CalendarSync\CalendarSyncInfo; use models\summit\CalendarSync\CalendarSyncInfo;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
/** /**
@ -59,6 +60,12 @@ final class MemberActionsCalendarSyncProcessingCommand extends Command
public function handle() public function handle()
{ {
$enabled = boolval(Config::get("cal_sync.enable_cal_sync", true));
if(!$enabled){
$this->info("task is not enabled!");
return false;
}
$batch_size = $this->argument('batch_size'); $batch_size = $this->argument('batch_size');
$provider = $this->argument('provider'); $provider = $this->argument('provider');
if(!CalendarSyncInfo::isValidProvider($provider)){ if(!CalendarSyncInfo::isValidProvider($provider)){

17
config/cal_sync.php Normal file
View File

@ -0,0 +1,17 @@
<?php
/**
* Copyright 2019 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.
**/
return [
'enable_cal_sync'=> env('ENABLE_CAL_SYNC', true),
];