refactor: refs #7457 Added from param if not exists #2502
|
@ -22,7 +22,7 @@ module.exports = Self => {
|
||||||
}, {
|
}, {
|
||||||
arg: 'from',
|
arg: 'from',
|
||||||
type: 'date',
|
type: 'date',
|
||||||
description: 'The from date'
|
description: 'The from date',
|
||||||
pablone marked this conversation as resolved
|
|||||||
}, {
|
}, {
|
||||||
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
se quedà que se deu de poder consultar tots els tickets d'un client. Que havent un limit no deuria anar lento. La solució no es obligar a pasar parametros.