fix: tiene el cuenta zonEvent.type
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-01-27 08:59:28 +01:00
parent 5d19da48e2
commit f7969c616c
1 changed files with 24 additions and 21 deletions

View File

@ -31,27 +31,30 @@ module.exports = Self => {
Object.assign(myOptions, options);
query = `
SELECT *
FROM (
SELECT
DISTINCT z.id,
z.name,
am.name agencyModeName,
IFNULL(ze.hour, z.hour) as hour,
IFNULL(ze.price, z.price) as price
FROM vn.zone z
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.zoneEvent ze ON ze.zoneFk = z.id
WHERE
(
ze.dated = ?
OR ? BETWEEN ze.started AND ze.ended
OR ze.weekDays & (1 << WEEKDAY(?))
)
AND z.id IN (?)
ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z
GROUP BY z.id;`;
SELECT *
FROM (
SELECT
DISTINCT z.id,
z.name,
am.name agencyModeName,
IFNULL(ze.hour, z.hour) as hour,
IFNULL(ze.price, z.price) as price
FROM vn.zone z
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.zoneEvent ze ON ze.zoneFk = z.id
WHERE ((
ze.type = 'day'
AND ze.dated = ?
) OR (
ze.type != 'day'
AND ze.weekDays & (1 << WEEKDAY(?))
AND (ze.started IS NULL OR ? >= ze.started)
AND (ze.ended IS NULL OR ? <= ze.ended)
))
AND z.id IN (?)
ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z
GROUP BY z.id`;
return Self.rawSql(query, [date, date, date, zoneIds], myOptions);
return Self.rawSql(query, [date, date, date, date, zoneIds], myOptions);
};
};