refactor(order): index filter optimization
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
c0e1f2f0dc
commit
e278491ad2
|
@ -119,7 +119,7 @@ module.exports = Self => {
|
|||
case 'sourceApp':
|
||||
return {'o.source_app': value};
|
||||
case 'ticketFk':
|
||||
return {'ort.ticketFk': value};
|
||||
return {'ot.ticketFk': value};
|
||||
case 'isConfirmed':
|
||||
return {'o.confirmed': value ? 1 : 0};
|
||||
case 'myTeam':
|
||||
|
@ -137,7 +137,10 @@ module.exports = Self => {
|
|||
let stmt;
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`SELECT
|
||||
`CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT
|
||||
o.id,
|
||||
o.total,
|
||||
o.date_send landed,
|
||||
|
@ -168,20 +171,20 @@ module.exports = Self => {
|
|||
LEFT JOIN ticket t ON t.id = ot.ticketFk
|
||||
LEFT JOIN zoneEstimatedDelivery zed ON zed.zoneFk = t.zoneFk`);
|
||||
|
||||
if (args && args.ticketFk) {
|
||||
stmt.merge({
|
||||
sql: `LEFT JOIN orderTicket ort ON ort.orderFk = o.id`
|
||||
});
|
||||
}
|
||||
|
||||
stmt.merge(conn.makeWhere(filter.where));
|
||||
stmt.merge(`GROUP BY o.id`);
|
||||
stmt.merge(conn.makePagination(filter));
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(`SELECT * FROM tmp.filter`);
|
||||
stmt.merge(`GROUP BY id`);
|
||||
stmt.merge(conn.makeOrderBy(filter.order));
|
||||
const ordersIndex = stmts.push(stmt) - 1;
|
||||
|
||||
stmts.push(`DROP TEMPORARY TABLE tmp.filter`);
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await conn.executeStmt(sql);
|
||||
|
||||
return result;
|
||||
return result[ordersIndex];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<vn-th field="landed" shrink-date>Landed</vn-th>
|
||||
<vn-th field="created" center>Hour</vn-th>
|
||||
<vn-th field="agencyName" center>Agency</vn-th>
|
||||
<vn-th center>Total</vn-th>
|
||||
<vn-th field="total" center>Total</vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
|
|
Loading…
Reference in New Issue