fix: consider additional hotelcodes for contingent calendar, add index
This commit is contained in:
+13
-17
@@ -58,13 +58,16 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
$qb = $this->getDbConnection()->createQueryBuilder();
|
$qb = $this->getDbConnection()->createQueryBuilder();
|
||||||
|
|
||||||
$qb
|
$qb
|
||||||
->select('status as status', 'date as date', 'min_price as minPrice', 'pax', 'available', 'room_code')
|
->select('c.status as status', 'c.date as date', 'c.min_price as minPrice', 'c.pax', 'c.available', 'c.room_code')
|
||||||
->from('tx_epproducts_domain_model_contingent')
|
->innerJoin('c', 'tx_epproducts_domain_model_hotel', 'h', 'c.hotel = h.uid')
|
||||||
->where('hotel = :hotelUid')
|
->leftJoin('c', 'tx_epproducts_domain_model_matchcode', 'm', 'h.uid = m.entity AND m.entity_type = "hotel"')
|
||||||
->andWhere('date >= :dateFrom')
|
->from('tx_epproducts_domain_model_contingent', 'c')
|
||||||
|
->where('c.hotel = :hotelUid')
|
||||||
|
->orWhere('c.hotel_code = m.code')
|
||||||
|
->andWhere('c.date >= :dateFrom')
|
||||||
->setParameter('hotelUid', $hotel->getUid())
|
->setParameter('hotelUid', $hotel->getUid())
|
||||||
->setParameter('dateFrom', $begin->format('Y-m-d'))
|
->setParameter('dateFrom', $begin->format('Y-m-d'))
|
||||||
->orderBy('date')
|
->orderBy('c.date')
|
||||||
;
|
;
|
||||||
|
|
||||||
if (null !== $end) {
|
if (null !== $end) {
|
||||||
@@ -78,8 +81,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
|
|
||||||
$dates = [];
|
$dates = [];
|
||||||
|
|
||||||
foreach ($result as $row)
|
foreach ($result as $row) {
|
||||||
{
|
|
||||||
if (!\array_key_exists($row['date'], $dates)) {
|
if (!\array_key_exists($row['date'], $dates)) {
|
||||||
$dates[$row['date']] = [
|
$dates[$row['date']] = [
|
||||||
'status' => Contingent::STATUS_OK,
|
'status' => Contingent::STATUS_OK,
|
||||||
@@ -88,7 +90,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
'available' => 0,
|
'available' => 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if ($row['status'] !== Contingent::STATUS_OK) {
|
if (Contingent::STATUS_OK !== $row['status']) {
|
||||||
$dates[$row['date']]['status'] = $row['status'];
|
$dates[$row['date']]['status'] = $row['status'];
|
||||||
}
|
}
|
||||||
if ('BelKal' !== $row['room_code']) {
|
if ('BelKal' !== $row['room_code']) {
|
||||||
@@ -99,8 +101,7 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
|
|
||||||
$events = [];
|
$events = [];
|
||||||
|
|
||||||
foreach ($dates as $row)
|
foreach ($dates as $row) {
|
||||||
{
|
|
||||||
$row['hotel'] = $hotel;
|
$row['hotel'] = $hotel;
|
||||||
$events[] = Contingent::fromArray($row);
|
$events[] = Contingent::fromArray($row);
|
||||||
}
|
}
|
||||||
@@ -109,9 +110,8 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Hotel $hotel
|
|
||||||
* @param Product $product
|
|
||||||
* @return array
|
* @return array
|
||||||
|
*
|
||||||
* @throws DBALException
|
* @throws DBALException
|
||||||
*/
|
*/
|
||||||
public function getAvailableContingents(Hotel $hotel, Product $product)
|
public function getAvailableContingents(Hotel $hotel, Product $product)
|
||||||
@@ -140,11 +140,8 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $dateFrom
|
|
||||||
* @param string $dateTo
|
|
||||||
* @param Hotel $hotel
|
|
||||||
* @param Product $product
|
|
||||||
* @return array
|
* @return array
|
||||||
|
*
|
||||||
* @throws DBALException
|
* @throws DBALException
|
||||||
*/
|
*/
|
||||||
public function getAvailableRooms(string $dateFrom, string $dateTo, Hotel $hotel, Product $product)
|
public function getAvailableRooms(string $dateFrom, string $dateTo, Hotel $hotel, Product $product)
|
||||||
@@ -178,5 +175,4 @@ class ContingentRepository extends AbstractRepository implements ProviderInterfa
|
|||||||
|
|
||||||
return $qb->execute()->fetchAllAssociative();
|
return $qb->execute()->fetchAllAssociative();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,8 +285,8 @@ CREATE TABLE tx_epproducts_domain_model_hotel
|
|||||||
PRIMARY KEY (uid),
|
PRIMARY KEY (uid),
|
||||||
KEY parent (pid),
|
KEY parent (pid),
|
||||||
KEY t3ver_oid (t3ver_oid, t3ver_wsid),
|
KEY t3ver_oid (t3ver_oid, t3ver_wsid),
|
||||||
KEY language (l10n_parent, sys_language_uid)
|
KEY language (l10n_parent, sys_language_uid),
|
||||||
|
KEY idx_hotel_uid (uid, deleted, hidden, starttime, endtime)
|
||||||
);
|
);
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -859,8 +859,8 @@ CREATE TABLE tx_epproducts_domain_model_matchcode
|
|||||||
PRIMARY KEY (uid),
|
PRIMARY KEY (uid),
|
||||||
KEY parent (pid),
|
KEY parent (pid),
|
||||||
KEY t3ver_oid (t3ver_oid, t3ver_wsid),
|
KEY t3ver_oid (t3ver_oid, t3ver_wsid),
|
||||||
KEY language (l10n_parent, sys_language_uid)
|
KEY language (l10n_parent, sys_language_uid),
|
||||||
|
KEY idx_matchcode_entity_type (entity, entity_type, deleted, hidden, starttime, endtime)
|
||||||
);
|
);
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -1187,8 +1187,9 @@ CREATE TABLE tx_epproducts_domain_model_contingent
|
|||||||
KEY parent (pid),
|
KEY parent (pid),
|
||||||
KEY t3ver_oid (t3ver_oid, t3ver_wsid),
|
KEY t3ver_oid (t3ver_oid, t3ver_wsid),
|
||||||
KEY language (l10n_parent, sys_language_uid),
|
KEY language (l10n_parent, sys_language_uid),
|
||||||
KEY groups (date, hotel)
|
KEY groups (date, hotel),
|
||||||
|
KEY idx_contingent_hotel_date (hotel, date, deleted, hidden, starttime, endtime),
|
||||||
|
KEY idx_contingent_hotel_code_date (hotel_code, date, deleted, hidden, starttime, endtime)
|
||||||
);
|
);
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user