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')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
const issued = Date.vnNew();
|
||||||
const where = buildFilter(args, (param, value) => {
|
const where = buildFilter(args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
|
case 'daysAgo':
|
||||||
|
issued.setDate(issued.getDate() - value);
|
||||||
|
return {'i.issued': {gte: issued}};
|
||||||
case 'serial':
|
case 'serial':
|
||||||
return {'f.serial': {like: `%${value}%`}};
|
return {'i.serial': {like: `%${value}%`}};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
filter = mergeFilters(args.filter, {where});
|
filter = mergeFilters(args.filter, {where});
|
||||||
const issued = Date.vnNew();
|
|
||||||
issued.setDate(issued.getDate() - args.daysAgo);
|
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
const stmt = new ParameterizedSQL(
|
const stmt = new ParameterizedSQL(
|
||||||
`SELECT *
|
`SELECT i.serial, SUM(IF(i.isBooked, 0,1)) pending, COUNT(*) total
|
||||||
FROM (
|
FROM vn.invoiceIn i`
|
||||||
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]);
|
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
|
stmt.merge(`GROUP BY i.serial`);
|
||||||
stmt.merge(conn.makeOrderBy(filter.order));
|
stmt.merge(conn.makeOrderBy(filter.order));
|
||||||
stmt.merge(conn.makeLimit(filter));
|
stmt.merge(conn.makeLimit(filter));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue