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 24 additions and 21 deletions
Showing only changes of commit f7969c616c - Show all commits
modules/zone/back/methods/zone

View File

@ -31,27 +31,30 @@ module.exports = Self => {
Object.assign(myOptions, options);
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 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 *
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.type = 'day'
AND ze.dated = ?
) OR (
ze.type != 'day'
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 ze.weekDays & (1 << WEEKDAY(?))
AND (ze.started IS NULL OR ? >= ze.started)
AND (ze.ended IS NULL OR ? <= ze.ended)
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.
))
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.
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);
vicent marked this conversation as resolved Outdated
Outdated
Review

Pasar date en lugar de dayName

Pasar `date` en lugar de `dayName`
};
};