#6964 _ itemOlder #2197

Merged
sergiodt merged 26 commits from 6964_itemOlder into dev 2024-04-04 14:18:20 +00:00
1 changed files with 14 additions and 12 deletions
Showing only changes of commit 22f78dbb91 - Show all commits

View File

@ -1,3 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('hasItemOlder', {
description:
@ -35,23 +36,24 @@ module.exports = Self => {
});
sergiodt marked this conversation as resolved Outdated
Outdated
Review

Els 3(parking, shelvingFkOut, itemFk) poden ser null a la vega? O faria falta al menys uno?
Per si fera falta ficar un if(!parking && !shelvingFkOut && !itemFk) return throw new UserError(...)

Els 3(parking, shelvingFkOut, itemFk) poden ser null a la vega? O faria falta al menys uno? Per si fera falta ficar un if(!parking && !shelvingFkOut && !itemFk) return throw new UserError(...)

Posat

Posat
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
sergiodt marked this conversation as resolved
Review
    const myOptions = {};

    if (typeof options == 'object')
        Object.assign(myOptions, options);
const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options);
if (!parking && !shelvingFkOut) throw new UserError('Missing data: parking or shelving');
sergiodt marked this conversation as resolved Outdated

Millor fiquem un alias al cam

Millor fiquem un alias al cam
Review

Faltaria la traduccion

Faltaria la traduccion
Review

Afegida

Afegida
const result = await Self.rawSql(`
sergiodt marked this conversation as resolved Outdated

Tabulació

Tabulació
SELECT COUNT(ish.id)
FROM vn.itemShelving ish
JOIN (
SELECT ish.itemFk, created,shelvingFk, p.code
FROM vn.itemShelving ish
JOIN vn.shelving s ON ish.shelvingFk = s.code
LEFT JOIN vn.parking p ON p.id = s.parkingFk
WHERE ish.shelvingFk = ?
SELECT COUNT(ish.id) countItemOlder
FROM vn.itemShelving ish
JOIN (
SELECT ish.itemFk, created,shelvingFk, p.code
FROM vn.itemShelving ish
JOIN vn.shelving s ON ish.shelvingFk = s.code
LEFT JOIN vn.parking p ON p.id = s.parkingFk
WHERE ish.shelvingFk = ?
sergiodt marked this conversation as resolved Outdated

Tabulació

Tabulació
)sub ON sub.itemFK = ish.itemFk
sergiodt marked this conversation as resolved Outdated

en la subconsulta el p.code y el LEFT JOIN vn.parking p ON p.id = s.parkingFk sirven para algo??

en la subconsulta el p.code y el LEFT JOIN vn.parking p ON p.id = s.parkingFk sirven para algo??

Llevat

Llevat
JOIN vn.shelving s ON s.code = ish.shelvingFk
JOIN vn.parking p ON p.id = s.parkingFk
WHERE sub.created > ish.created
JOIN vn.shelving s ON s.code = ish.shelvingFk
JOIN vn.parking p ON p.id = s.parkingFk
WHERE sub.created > ish.created
AND (p.code <> ? OR ? IS NULL)
AND (ish.shelvingFk <> ? OR ? IS NULL)
sergiodt marked this conversation as resolved Outdated
Outdated
Review

falta gastar la transaccio (...shelvingFkOut, itemFk, itemFk], options)

falta gastar la transaccio (...shelvingFkOut, itemFk, itemFk], options)

Llevat options

Llevat options
Outdated
Review

Es ficarlo sino no gastarà la transaccio

Es ficarlo sino no gastarà la transaccio

L'he posat però no veia que fera falta...

L'he posat però no veia que fera falta...
AND (ish.itemFk <> ? OR ? IS NULL)`,
sergiodt marked this conversation as resolved Outdated
Outdated
Review

Si li poses el alias aci hi ha que canviarlo

Si li poses el alias aci hi ha que canviarlo
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
sergiodt marked this conversation as resolved Outdated
Outdated
Review

Aci

Aci
Outdated
Review

myOptions

myOptions
return result[0]['COUNT(ish.id)'] > 0;
return result[0]['countItemOlder'] > 0;
};
};