feat: refs #7884 added filter when daysOnward and daysAgo have value and refactor ifs block
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
1d47690bb4
commit
71362baa66
|
@ -221,24 +221,33 @@ module.exports = Self => {
|
|||
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
||||
);
|
||||
|
||||
if (ctx.args.daysOnward) {
|
||||
stmt.merge({
|
||||
sql: `
|
||||
AND t.shipped <= util.VN_CURDATE() + INTERVAL ? DAY
|
||||
AND t.shipped >= util.VN_CURDATE()
|
||||
`,
|
||||
params: [ctx.args.daysOnward]
|
||||
});
|
||||
}
|
||||
const {daysAgo, daysOnward} = ctx.args;
|
||||
|
||||
if (ctx.args.daysAgo) {
|
||||
stmt.merge({
|
||||
sql: `
|
||||
if (daysAgo || daysOnward) {
|
||||
let sql = '';
|
||||
const params = [];
|
||||
|
||||
if (daysAgo && daysOnward) {
|
||||
sql = `
|
||||
AND t.shipped >= util.VN_CURDATE() - INTERVAL ? DAY
|
||||
AND t.shipped <= util.VN_CURDATE() + INTERVAL ? DAY
|
||||
`;
|
||||
params.push(daysAgo, daysOnward);
|
||||
} else if (daysAgo) {
|
||||
sql = `
|
||||
AND t.shipped >= util.VN_CURDATE() - INTERVAL ? DAY
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
`,
|
||||
params: [ctx.args.daysAgo]
|
||||
});
|
||||
`;
|
||||
params.push(daysAgo);
|
||||
} else if (daysOnward) {
|
||||
sql = `
|
||||
AND t.shipped <= util.VN_CURDATE() + INTERVAL ? DAY
|
||||
AND t.shipped >= util.VN_CURDATE()
|
||||
`;
|
||||
params.push(daysOnward);
|
||||
}
|
||||
|
||||
stmt.merge({sql, params});
|
||||
}
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
|
Loading…
Reference in New Issue