refs #5184 subselect deleted
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
4a84ceba53
commit
3ad85c0de3
|
@ -35,28 +35,27 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const issued = Date.vnNew();
|
||||
const where = buildFilter(args, (param, value) => {
|
||||
switch (param) {
|
||||
case 'daysAgo':
|
||||
issued.setDate(issued.getDate() - value);
|
||||
return {'i.issued': {gte: issued}};
|
||||
case 'serial':
|
||||
return {'f.serial': {like: `%${value}%`}};
|
||||
return {'i.serial': {like: `%${value}%`}};
|
||||
}
|
||||
});
|
||||
|
||||
filter = mergeFilters(args.filter, {where});
|
||||
const issued = Date.vnNew();
|
||||
issued.setDate(issued.getDate() - args.daysAgo);
|
||||
|
||||
const stmts = [];
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT *
|
||||
FROM (
|
||||
SELECT i.serial, SUM(IF(i.isBooked, 0,1)) pending, COUNT(*) total
|
||||
FROM vn.invoiceIn i
|
||||
WHERE i.issued >= ?
|
||||
GROUP BY i.serial) f`
|
||||
, [issued]);
|
||||
`SELECT i.serial, SUM(IF(i.isBooked, 0,1)) pending, COUNT(*) total
|
||||
FROM vn.invoiceIn i`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
stmt.merge(`GROUP BY i.serial`);
|
||||
stmt.merge(conn.makeOrderBy(filter.order));
|
||||
stmt.merge(conn.makeLimit(filter));
|
||||
|
||||
|
|
Loading…
Reference in New Issue