refactor: actualizada consulta sql
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3f7dee63ac
commit
5d19da48e2
|
@ -30,31 +30,28 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const dated = new Date(date);
|
||||
const dayName = dated.toString().split(' ')[0];
|
||||
|
||||
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 agencyMode am ON am.id = z.agencyModeFk
|
||||
LEFT JOIN zoneEvent ze ON ze.zoneFk = z.id
|
||||
WHERE
|
||||
(
|
||||
dated = ?
|
||||
OR ? BETWEEN started AND ended
|
||||
OR weekDays LIKE ?
|
||||
)
|
||||
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.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;`;
|
||||
|
||||
return Self.rawSql(query, [date, date, dayName, zoneIds], myOptions);
|
||||
return Self.rawSql(query, [date, date, date, zoneIds], myOptions);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue