fix: corregido sql
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-01-10 13:31:20 +01:00
parent 1f1a69a2b4
commit 484b8d42e1
1 changed files with 9 additions and 6 deletions

View File

@ -30,6 +30,9 @@ module.exports = Self => {
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
const dated = new Date(date);
const dayName = dated.toString().split(' ')[0];
query = ` query = `
SELECT * SELECT *
FROM ( FROM (
@ -46,12 +49,12 @@ module.exports = Self => {
( (
dated = ? dated = ?
OR ? BETWEEN started AND ended OR ? BETWEEN started AND ended
OR INSTR(weekDays, SUBSTRING(DAYNAME(?), 1, 3) ) > 0 OR weekDays LIKE ?
) )
AND z.id IN (?) AND z.id IN (?)
ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z
GROUP BY z.id`; GROUP BY z.id`;
return Self.rawSql(query, [date, date, date, zoneIds], myOptions); return Self.rawSql(query, [date, date, dayName, zoneIds], myOptions);
}; };
}; };