4873-zone.delivery-day #1248

Merged
vicent merged 8 commits from 4873-zone.delivery-day into dev 2023-02-03 12:28:36 +00:00
1 changed files with 21 additions and 24 deletions
Showing only changes of commit 5d19da48e2 - Show all commits

View File

@ -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 = `
vicent marked this conversation as resolved Outdated
Outdated
Review

Esto es necesario? Si se define el argumento como tipo Date debería llegar una fecha

Esto es necesario? Si se define el argumento como tipo Date debería llegar una fecha
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 *
vicent marked this conversation as resolved Outdated
Outdated
Review

No nesario si se pasa directamente date a la función

No nesario si se pasa directamente date a la función
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(?))
vicent marked this conversation as resolved Outdated
Outdated
Review

S'ha de tindre en compte tambe la columna type de zoneEvent, mira el WHERE del procediment vn.zone_getOptionsForLanding

S'ha de tindre en compte tambe la columna `type` de `zoneEvent`, mira el WHERE del procediment `vn.zone_getOptionsForLanding`

Pero aixo ja ho fa:

 WHERE
                        (
                            ze.dated = ?
                            OR ? BETWEEN ze.started AND ze.ended
                            OR ze.weekDays & (1 << WEEKDAY(?))
                        )

pq depen del camps q tinga rellenats es un type o altre.

Pero aixo ja ho fa: ``` WHERE ( ze.dated = ? OR ? BETWEEN ze.started AND ze.ended OR ze.weekDays & (1 << WEEKDAY(?)) ) ``` pq depen del camps q tinga rellenats es un type o altre.

Vale res, he vist q pot tindre started, ended y weekDays rellenat. Pensava q eren exclusius.

Vale res, he vist q pot tindre started, ended y weekDays rellenat. Pensava q eren exclusius.
)
AND z.id IN (?)
ORDER BY type='day' DESC, type='range' DESC, type='indefinitely' DESC) z
vicent marked this conversation as resolved Outdated
Outdated
Review

Pasar la fecha directamnte y comparar así: ze.weekDays & (1 << WEEKDAY(?))

Además hay que tener en cuenta el tipo de evento type.

Todas las columnas de la consulta debería llevar el alias de la tabla.

Pasar la fecha directamnte y comparar así: `ze.weekDays & (1 << WEEKDAY(?))` Además hay que tener en cuenta el tipo de evento `type`. Todas las columnas de la consulta debería llevar el alias de la tabla.
GROUP BY z.id;`;
vicent marked this conversation as resolved Outdated
Outdated
Review

N'hi ha una tabulació de mes en tota la consulta, punt i coma no fa falta al final si nomes es una consulta.

N'hi ha una tabulació de mes en tota la consulta, punt i coma no fa falta al final si nomes es una consulta.
return Self.rawSql(query, [date, date, dayName, zoneIds], myOptions);
return Self.rawSql(query, [date, date, date, zoneIds], myOptions);
};
};