Merge branch 'dev' of http://git.verdnatura.es/salix into dev
This commit is contained in:
commit
5cfd5c7605
|
@ -1,9 +1,9 @@
|
||||||
USE `vn`;
|
USE `vn`;
|
||||||
DROP procedure IF EXISTS `ticketGetFullList`;
|
DROP procedure IF EXISTS `ticketFilter`;
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
USE `vn`$$
|
USE `vn`$$
|
||||||
CREATE DEFINER=`root`@`%` PROCEDURE `ticketGetFullList`()
|
CREATE DEFINER=`root`@`%` PROCEDURE `ticketFilter`()
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Obtiene un listado de tickets
|
* Obtiene un listado de tickets
|
||||||
|
@ -15,8 +15,8 @@ BEGIN
|
||||||
CALL ticketGetTotal();
|
CALL ticketGetTotal();
|
||||||
CALL ticketGetProblems();
|
CALL ticketGetProblems();
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketFullList;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticketFilter;
|
||||||
CREATE TEMPORARY TABLE tmp.ticketFullList ENGINE = MEMORY
|
CREATE TEMPORARY TABLE tmp.ticketFilter ENGINE = MEMORY
|
||||||
SELECT t.*, tt.total, tp.problem
|
SELECT t.*, tt.total, tp.problem
|
||||||
FROM tmp.ticket t
|
FROM tmp.ticket t
|
||||||
JOIN tmp.ticketTotal tt ON tt.ticketFk = t.ticketFk
|
JOIN tmp.ticketTotal tt ON tt.ticketFk = t.ticketFk
|
|
@ -24,9 +24,13 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.filter = async filter => {
|
Self.filter = async filter => {
|
||||||
let stmt = new ParameterizedSQL(
|
let stmts = [];
|
||||||
`DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
let stmt;
|
||||||
CREATE TEMPORARY TABLE tmp.ticket
|
|
||||||
|
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.ticket');
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`CREATE TEMPORARY TABLE tmp.ticket
|
||||||
(PRIMARY KEY (ticketFk)) ENGINE = MEMORY
|
(PRIMARY KEY (ticketFk)) ENGINE = MEMORY
|
||||||
SELECT
|
SELECT
|
||||||
t.id,
|
t.id,
|
||||||
|
@ -54,15 +58,21 @@ module.exports = Self => {
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||||
LEFT JOIN state st ON st.id = ts.stateFk
|
LEFT JOIN state st ON st.id = ts.stateFk
|
||||||
LEFT JOIN client c ON c.id = t.clientFk
|
LEFT JOIN client c ON c.id = t.clientFk
|
||||||
LEFT JOIN worker wk ON wk.id = c.salesPersonFk`);
|
LEFT JOIN worker wk ON wk.id = c.salesPersonFk`);
|
||||||
|
|
||||||
stmt.merge(Self.buildSuffix(filter, 't'));
|
stmt.merge(Self.buildSuffix(filter, 't'));
|
||||||
stmt.merge(';CALL ticketGetFullList()');
|
stmts.push(stmt);
|
||||||
stmt.merge(';SELECT * FROM tmp.ticketFullList tfl');
|
|
||||||
|
stmts.push('CALL ticketFilter()');
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`SELECT * FROM tmp.ticketFilter tfl`
|
||||||
|
);
|
||||||
stmt.merge(Self.buildSuffix(filter, 'tfl'));
|
stmt.merge(Self.buildSuffix(filter, 'tfl'));
|
||||||
|
let rsIndex = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
let result = await Self.rawStmt(stmt);
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
let tickets = await Self.rawStmt(sql);
|
||||||
|
|
||||||
return result[3];
|
return tickets[rsIndex];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue