openstackid-resources/app/Jobs/ProcessEventDataImport.php
smarcet 3cd4efefba Import Session data through CSV file
Minimal data required

title ( text )
abstract (text )
type_id (int) or type (string type name)
track_id (int) or track ( string track name)

Optional fields

social_summary ( text )
attendees_expected_learnt ( text ) * provided only if event is presentation type
location (id or name)
level (text possible values [N/A, Beginner, Intermediate, Advanced]) * provided only if event is presentation type
allow_feedback (int possible values [0,1])
to_record (int possible values [0,1])
tags ( repetitive group: values | delimited)
sponsors ( repetitive group : names | delimited )
speakers ( repetitive group:  emails | delimited )
start_date (mandatory if is_published is 1) Y-m-d H:i:s format ( summit time zone )
end_date (mandatory if is_published is 1)  Y-m-d H:i:s format ( summit time zone )
is_published (int possible values [0,1]) , if this field is set 1 start_date and end_date are mandatories
selection_plan (string  selection plan name)  * provided only if event is presentation type
attendees_expected_learnt ( text , only presentations)
problem_addressed ( text , only presentations)

added endpoint

POST /api/v1/summits/{summit_id}/events/csv

multipart/form-data

* Expected params

file
send_speaker_email

Change-Id: I245d4e1a22e2c5e3c4120c559d0ecb4a5a021c78
Signed-off-by: smarcet <smarcet@gmail.com>
2020-09-25 16:06:42 -03:00

80 lines
2.3 KiB
PHP

<?php namespace App\Jobs;
/**
* 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\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 models\exceptions\ValidationException;
use services\model\ISummitService;
/**
* Class ProcessEventDataImport
* @package App\Jobs
*/
class ProcessEventDataImport implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 2;
public $timeout = PHP_INT_MAX;
/**
* @var int
*/
private $summit_id;
/**
* @var string
*/
private $filename;
/**
* @var boolean
*/
private $send_speaker_email;
/**
* ProcessEventDataImport constructor.
* @param int $summit_id
* @param string $filename
* @param array $payload
*/
public function __construct(int $summit_id, string $filename, array $payload)
{
Log::debug(sprintf("ProcessEventDataImport::__construct"));
$this->summit_id = $summit_id;
$this->filename = $filename;
$this->send_speaker_email = boolval($payload['send_speaker_email']);
}
/**
* @param ISummitService $service
*/
public function handle
(
ISummitService $service
)
{
try {
Log::debug(sprintf("ProcessEventDataImport::handle summit %s filename %s send_speaker_email %s", $this->summit_id, $this->filename, $this->send_speaker_email));
$service->processEventData($this->summit_id, $this->filename, $this->send_speaker_email);
} catch (ValidationException $ex) {
Log::warning($ex);
} catch (\Exception $ex) {
Log::error($ex);
}
}
}