6964-hasItemOlder #2560

Merged
sergiodt merged 9 commits from 6964-hasItemOlder into test 2024-06-18 14:27:08 +00:00
1 changed files with 7 additions and 8 deletions
Showing only changes of commit 46cd20a1fd - Show all commits

View File

@ -17,7 +17,7 @@ module.exports = Self => {
},
],
returns: {
type: 'Object',
type: 'Array',
Outdated
Review

Return array

Return array
root: true
},
http: {
@ -31,7 +31,7 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const isParkingToReview = await Self.rawSql(`
const [isParkingToReview] = await Self.rawSql(`
SELECT COUNT(p.id) parkingToReview
FROM vn.parking p
JOIN vn.sector s ON s.id = p.sectorFk
@ -39,8 +39,9 @@ module.exports = Self => {
WHERE p.code = ? AND s.code = pc.sectorToCode;`,
[parking], myOptions);
if (isParkingToReview[0]['parkingToReview'] > 0) {
const result = await Self.rawSql(`
if (isParkingToReview['parkingToReview'] < 1) return [];
const result = await Self.rawSql(`
WITH tItemShelving AS(
SELECT is2.itemFk, is2.created, p.sectorFK, is2.id
FROM vn.itemShelving is2
@ -63,9 +64,7 @@ module.exports = Self => {
JOIN tItemInSector tis ON tis.itemFk = ti.itemFk
JOIN vn.productionConfig pc
WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`,
[shelvingFk, shelvingFk], myOptions);
return result;
} else
return [];
[shelvingFk, shelvingFk], myOptions);
Outdated
Review

Si no hi ha resultats de per si ja torna array vuit, no cal ficar el if else

const [isParkingToReview] = await Self.rawSql(`
    SELECT COUNT(p.id) parkingToReview
    FROM vn.parking p 
        JOIN vn.sector s ON s.id = p.sectorFk
        JOIN vn.productionConfig pc
    WHERE p.code = ? AND s.code = pc.sectorToCode;`,
[parking], myOptions);

if (isParkingToReview['parkingToReview'] < 1) return []
Si no hi ha resultats de per si ja torna array vuit, no cal ficar el if else ``` const [isParkingToReview] = await Self.rawSql(` SELECT COUNT(p.id) parkingToReview FROM vn.parking p JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.productionConfig pc WHERE p.code = ? AND s.code = pc.sectorToCode;`, [parking], myOptions); if (isParkingToReview['parkingToReview'] < 1) return [] ```
return result;
};
};