Merge branch 'release/2020.03-05'

This commit is contained in:
Björn Fromme
2020-03-09 18:11:09 +01:00
3 changed files with 51 additions and 51 deletions
+4 -1
View File
@@ -20,7 +20,10 @@ provider: default
omit_containers: [dba]
use_dns_when_possible: true
timezone: Europe/Berlin
hooks:
post-start:
- exec: bash -c "sudo chown -R ${DDEV_UID}:${DDEV_GID} /var/www/html/vendor"
- exec: bash -c "sudo chown -R ${DDEV_UID}:${DDEV_GID} /var/www/html/var"
# This config.yaml was created with ddev version v1.13.1
# webimage: drud/ddev-webserver:v1.13.1
+19 -1
View File
@@ -3,4 +3,22 @@ version: '3.6'
services:
web:
environment:
- TYPO3_CONTEXT=Development/Ddev
- TYPO3_CONTEXT=Development/Ddev
- DDEV_UID
- DDEV_GID
volumes:
- type: volume
source: var
target: /var/www/html/var
volume:
nocopy: true
- type: volume
source: vendor
target: /var/www/html/vendor
volume:
nocopy: true
volumes:
vendor:
driver: local
var:
driver: local
@@ -121,12 +121,6 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
$this->resetChart($range, $config['key'], $config['number']);
// $this->generateAvailabilityChart(
// $events,
// $config['key'],
// $config['number']
// );
$this->generateChart(
$events,
$config['key'],
@@ -135,45 +129,6 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
}
}
/**
* @param array $events
* @param string $apiKey
* @param int $houseNumber
*/
protected function generateAvailabilityChart(array $events, $apiKey, $houseNumber): void
{
$itemCount = 0;
$occupancy = null;
foreach ($events as $event) {
/** @var Contingent $event */
if (null === $occupancy) {
$item = [
'from' => $event->getBegin(),
'occupancy' => $event->getOccupancy(),
];
} elseif ($occupancy !== $event->getOccupancy()) {
$item['to'] = $event->getEnd();
$this->addItem($item, 1, $apiKey, $houseNumber);
$item = [
'from' => $event->getBegin(),
'occupancy' => $event->getOccupancy(),
];
$itemCount++;
}
$occupancy = $event->getOccupancy();
}
if (!isset($item['to'])) {
$item['to'] = $event->getEnd();
$this->addItem($item, 1, $apiKey, $houseNumber);
$itemCount++;
}
$this->logger->info(sprintf('Published %d dates.', $itemCount));
}
/**
* @param Period $range
* @param string $apiKey
@@ -202,12 +157,13 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
foreach ($events as $event) {
/** @var Contingent $event */
if (null === $item && Contingent::STATUS_OK !== $event->getStatus()) {
$status = $event->getStatus();
$contingentStatus = $this->getContingentStatus($event);
if (null === $item && Contingent::STATUS_OK !== $contingentStatus) {
$status = $contingentStatus;
$item = [
'from' => $event->getBegin(),
];
} elseif (true === is_array($item) && $status !== $event->getStatus()) {
} elseif (true === is_array($item) && $status !== $contingentStatus) {
$item['to'] = $event->getEnd();
$statusCode = Contingent::STATUS_ONREQUEST === $status ? 1 : 2;
$this->addItem($item, $statusCode, $apiKey, $houseNumber);
@@ -216,7 +172,30 @@ class GroupsSwissService implements SingletonInterface, LoggerAwareInterface
}
}
$this->logger->info(sprintf('Published %d blocked dates.', $itemCount));
$this->logger->info(sprintf('Published %d dates.', $itemCount));
}
/**
* @param Contingent $contingent
* @return int
*/
protected function getContingentStatus(Contingent $contingent)
{
if (in_array($contingent->getStatus(), [Contingent::STATUS_BLOCKED, Contingent::STATUS_ONREQUEST], true)) {
return $contingent->getStatus();
}
$percentageAvailable = $contingent->getPercentageAvailable();
if ($percentageAvailable <= 20) {
return Contingent::STATUS_BLOCKED;
}
if ($percentageAvailable > 20 && $percentageAvailable <= 80) {
return $contingent::STATUS_ONREQUEST;
}
return Contingent::STATUS_OK;
}
/**