6964-hasItemOlder #2560
|
@ -17,7 +17,7 @@ module.exports = Self => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'Object',
|
type: 'Array',
|
||||||
|
|||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
http: {
|
http: {
|
||||||
|
@ -31,7 +31,7 @@ module.exports = Self => {
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const isParkingToReview = await Self.rawSql(`
|
const [isParkingToReview] = await Self.rawSql(`
|
||||||
SELECT COUNT(p.id) parkingToReview
|
SELECT COUNT(p.id) parkingToReview
|
||||||
FROM vn.parking p
|
FROM vn.parking p
|
||||||
JOIN vn.sector s ON s.id = p.sectorFk
|
JOIN vn.sector s ON s.id = p.sectorFk
|
||||||
|
@ -39,7 +39,8 @@ module.exports = Self => {
|
||||||
WHERE p.code = ? AND s.code = pc.sectorToCode;`,
|
WHERE p.code = ? AND s.code = pc.sectorToCode;`,
|
||||||
[parking], myOptions);
|
[parking], myOptions);
|
||||||
|
|
||||||
if (isParkingToReview[0]['parkingToReview'] > 0) {
|
if (isParkingToReview['parkingToReview'] < 1) return [];
|
||||||
|
|
||||||
const result = await Self.rawSql(`
|
const result = await Self.rawSql(`
|
||||||
WITH tItemShelving AS(
|
WITH tItemShelving AS(
|
||||||
SELECT is2.itemFk, is2.created, p.sectorFK, is2.id
|
SELECT is2.itemFk, is2.created, p.sectorFK, is2.id
|
||||||
|
@ -65,7 +66,5 @@ module.exports = Self => {
|
||||||
WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`,
|
WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`,
|
||||||
[shelvingFk, shelvingFk], myOptions);
|
[shelvingFk, shelvingFk], myOptions);
|
||||||
alexm
commented
Si no hi ha resultats de per si ja torna array vuit, no cal ficar el if else
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;
|
return result;
|
||||||
} else
|
|
||||||
return [];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Return array