Merge pull request 'refactor: refs #7457 Added from param if not exists' (!2502) from 7457-orderFilter into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2502 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
7a9bcf11e2
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
||||||
}, {
|
}, {
|
||||||
arg: 'from',
|
arg: 'from',
|
||||||
type: 'date',
|
type: 'date',
|
||||||
description: 'The from date'
|
description: 'The from date',
|
||||||
}, {
|
}, {
|
||||||
arg: 'to',
|
arg: 'to',
|
||||||
type: 'date',
|
type: 'date',
|
||||||
|
@ -84,7 +84,6 @@ module.exports = Self => {
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
const args = ctx.args;
|
const args = ctx.args;
|
||||||
|
|
||||||
// Apply filter by team
|
// Apply filter by team
|
||||||
const teamMembersId = [];
|
const teamMembersId = [];
|
||||||
if (args.myTeam != null) {
|
if (args.myTeam != null) {
|
||||||
|
@ -101,9 +100,12 @@ module.exports = Self => {
|
||||||
teamMembersId.push(userId);
|
teamMembersId.push(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args && args.myTeam)
|
if (args?.myTeam)
|
||||||
args.teamIds = teamIds;
|
args.teamIds = teamIds;
|
||||||
|
|
||||||
|
if (args?.to)
|
||||||
|
args.to.setHours(23, 59, 0, 0);
|
||||||
|
|
||||||
const where = buildFilter(args, (param, value) => {
|
const where = buildFilter(args, (param, value) => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'search':
|
case 'search':
|
||||||
|
@ -151,7 +153,12 @@ module.exports = Self => {
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||||
(INDEX (id))
|
(INDEX (id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT o.id,
|
WITH wOrderTicket AS(
|
||||||
|
SELECT orderFk,
|
||||||
|
ticketFk
|
||||||
|
FROM orderTicket
|
||||||
|
GROUP BY orderFk
|
||||||
|
)SELECT o.id,
|
||||||
o.total,
|
o.total,
|
||||||
o.date_send landed,
|
o.date_send landed,
|
||||||
o.date_make created,
|
o.date_make created,
|
||||||
|
@ -199,7 +206,6 @@ module.exports = Self => {
|
||||||
`);
|
`);
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
stmt.merge(`GROUP BY id`);
|
|
||||||
stmt.merge(conn.makePagination(filter));
|
stmt.merge(conn.makePagination(filter));
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`);
|
stmts.push(`SET SESSION optimizer_search_depth = @_optimizer_search_depth`);
|
||||||
|
@ -212,7 +218,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
const result = await conn.executeStmt(sql, myOptions);
|
const result = await conn.executeStmt(sql, myOptions);
|
||||||
|
|
||||||
return result[ordersIndex];
|
return result[ordersIndex];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue