diff --git a/.env.example b/.env.example index 83927d6a..83e1e4d2 100644 --- a/.env.example +++ b/.env.example @@ -76,4 +76,6 @@ CLOUD_STORAGE_AUTH_URL= CLOUD_STORAGE_USERNAME= CLOUD_STORAGE_APIKEY= CLOUD_STORAGE_PROJECT_NAME= -CLOUD_STORAGE_REGION= \ No newline at end of file +CLOUD_STORAGE_REGION= +# enable/disable cal sync background task +ENABLE_CAL_SYNC=true \ No newline at end of file diff --git a/app/Console/Commands/AdminActionsCalendarSyncProcessingCommand.php b/app/Console/Commands/AdminActionsCalendarSyncProcessingCommand.php index cb320609..99d49985 100644 --- a/app/Console/Commands/AdminActionsCalendarSyncProcessingCommand.php +++ b/app/Console/Commands/AdminActionsCalendarSyncProcessingCommand.php @@ -13,6 +13,8 @@ **/ use Illuminate\Console\Command; use App\Services\Model\IAdminActionsCalendarSyncProcessingService; +use Illuminate\Support\Facades\Config; + /** * Class AdminActionsCalendarSyncProcessingCommand * @package App\Console\Commands @@ -57,6 +59,12 @@ final class AdminActionsCalendarSyncProcessingCommand extends Command 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'); if(empty($batch_size)) $batch_size = PHP_INT_MAX; diff --git a/app/Console/Commands/MemberActionsCalendarSyncProcessingCommand.php b/app/Console/Commands/MemberActionsCalendarSyncProcessingCommand.php index 8bfe1d8d..2e0fa7ce 100644 --- a/app/Console/Commands/MemberActionsCalendarSyncProcessingCommand.php +++ b/app/Console/Commands/MemberActionsCalendarSyncProcessingCommand.php @@ -13,6 +13,7 @@ **/ use Illuminate\Console\Command; use App\Services\Model\IMemberActionsCalendarSyncProcessingService; +use Illuminate\Support\Facades\Config; use models\summit\CalendarSync\CalendarSyncInfo; use Illuminate\Support\Facades\Log; /** @@ -59,6 +60,12 @@ final class MemberActionsCalendarSyncProcessingCommand extends Command 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'); $provider = $this->argument('provider'); if(!CalendarSyncInfo::isValidProvider($provider)){ diff --git a/config/cal_sync.php b/config/cal_sync.php new file mode 100644 index 00000000..260c547f --- /dev/null +++ b/config/cal_sync.php @@ -0,0 +1,17 @@ + env('ENABLE_CAL_SYNC', true), +]; \ No newline at end of file