Added new Presentation.progress state
PHASE_UPLOAD Change-Id: Ib6a879e2862d5cdff22f473f2a1d31d0e96e4c0f Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
89838d398e
commit
7b27b05d72
@ -83,6 +83,13 @@ class PresentationMediaUpload extends PresentationMaterial
|
||||
$this->media_upload_type = $media_upload_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isMandatory():bool{
|
||||
return $this->media_upload_type->isMandatory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -57,21 +57,25 @@ class Presentation extends SummitEvent
|
||||
*/
|
||||
const PHASE_SUMMARY = 1;
|
||||
|
||||
/**
|
||||
* defines a phase where a presentation has a UPLOADS
|
||||
*/
|
||||
const PHASE_UPLOADS = 2;
|
||||
|
||||
/**
|
||||
* defines a phase where a presentation has a tags
|
||||
*/
|
||||
const PHASE_TAGS = 2;
|
||||
const PHASE_TAGS = 3;
|
||||
|
||||
/**
|
||||
* defines a phase where a presentation has a summary and speakers
|
||||
*/
|
||||
const PHASE_SPEAKERS = 3;
|
||||
|
||||
const PHASE_SPEAKERS = 4;
|
||||
|
||||
/**
|
||||
* Defines a phase where a presentation has been submitted successfully
|
||||
*/
|
||||
const PHASE_COMPLETE = 4;
|
||||
const PHASE_COMPLETE = 5;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -625,6 +629,9 @@ class Presentation extends SummitEvent
|
||||
case self::PHASE_SUMMARY:
|
||||
return 'SUMMARY';
|
||||
break;
|
||||
case self::PHASE_UPLOADS:
|
||||
return 'UPLOADS';
|
||||
break;
|
||||
case self::PHASE_TAGS:
|
||||
return 'TAGS';
|
||||
break;
|
||||
@ -658,9 +665,10 @@ class Presentation extends SummitEvent
|
||||
/**
|
||||
* @param int $progress
|
||||
*/
|
||||
public function setProgress($progress)
|
||||
public function setProgress(int $progress)
|
||||
{
|
||||
$this->progress = $progress;
|
||||
if($this->progress < $progress)
|
||||
$this->progress = $progress;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1004,4 +1012,13 @@ class Presentation extends SummitEvent
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMediaUploadsMandatoryCount():int{
|
||||
return $this->materials->filter(function( $element) {
|
||||
return $element instanceof PresentationMediaUpload && $element->isMandatory();
|
||||
})->count();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4839,6 +4839,29 @@ SQL;
|
||||
return $type === false ? null : $type;
|
||||
}
|
||||
|
||||
|
||||
public function getMediaUploadsMandatoryCount():int {
|
||||
try {
|
||||
$sql = <<<SQL
|
||||
SELECT COUNT(SummitMediaUploadType.ID) AS QTY
|
||||
FROM SummitMediaUploadType
|
||||
WHERE
|
||||
SummitMediaUploadType.SummitID = :summit_id
|
||||
AND SummitMediaUploadType.IsMandatory = 1
|
||||
SQL;
|
||||
$stmt = $this->prepareRawSQL($sql);
|
||||
$stmt->execute([
|
||||
'summit_id' => $this->id,
|
||||
]);
|
||||
$res = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||
$count = count($res) > 0 ? $res[0] : 0;
|
||||
} catch (\Exception $ex) {
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return SummitMediaUploadType|null
|
||||
|
@ -28,6 +28,7 @@ use App\Services\Model\AbstractService;
|
||||
use App\Models\Foundation\Summit\Events\Presentations\TrackQuestions\TrackAnswer;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\main\IFolderRepository;
|
||||
@ -995,6 +996,7 @@ final class PresentationService
|
||||
$payload
|
||||
) {
|
||||
|
||||
Log::debug(sprintf("PresentationService::addMediaUploadTo summit %s presentation %s", $summit->getId(), $presentation_id));
|
||||
$presentation = $this->presentation_repository->getById($presentation_id);
|
||||
|
||||
if (is_null($presentation) || !$presentation instanceof Presentation)
|
||||
@ -1069,6 +1071,21 @@ final class PresentationService
|
||||
$mediaUpload->setFilename($fileName);
|
||||
$presentation->addMediaUpload($mediaUpload);
|
||||
|
||||
if(!$presentation->isCompleted()){
|
||||
Log::debug(sprintf("PresentationService::addMediaUploadTo presentation %s is not complete", $presentation_id));
|
||||
$summitMediaUploadCount = $summit->getMediaUploadsMandatoryCount();
|
||||
Log::debug(sprintf("PresentationService::addMediaUploadTo presentation %s got summitMediaUploadCount %s", $presentation_id, $summitMediaUploadCount));
|
||||
if($summitMediaUploadCount == 0) {
|
||||
Log::debug(sprintf("PresentationService::addMediaUploadTo presentation %s marking as PHASE_UPLOADS ( no mandatories uploads)", $presentation_id));
|
||||
$presentation->setProgress(Presentation::PHASE_UPLOADS);
|
||||
}
|
||||
|
||||
if($summitMediaUploadCount > 0 && $summitMediaUploadCount == $presentation->getMediaUploadsMandatoryCount()){
|
||||
Log::debug(sprintf("PresentationService::addMediaUploadTo presentation %s marking as PHASE_UPLOADS ( mandatories completed)", $presentation_id));
|
||||
$presentation->setProgress(Presentation::PHASE_UPLOADS);
|
||||
}
|
||||
}
|
||||
|
||||
return $mediaUpload;
|
||||
});
|
||||
}
|
||||
|
50
database/migrations/model/Version20201021172434.php
Normal file
50
database/migrations/model/Version20201021172434.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
/**
|
||||
* Class Version20201021172434
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
class Version20201021172434 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
update Presentation set Progress = 5 where Progress = 4;
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
$sql = <<<SQL
|
||||
update Presentation set Progress = 4 where Progress = 3;
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
|
||||
$sql = <<<SQL
|
||||
update Presentation set Progress = 3 where Progress = 2;
|
||||
SQL;
|
||||
$this->addSql($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user