This commit is contained in:
parent
5ce33fbefd
commit
4729a7e9a9
|
@ -0,0 +1,17 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`routeUpdateM3`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`routeUpdateM3`(vRoute INT)
|
||||
BEGIN
|
||||
|
||||
UPDATE vn.route r
|
||||
JOIN (SELECT routeFk, SUM(volume) AS m3
|
||||
FROM ticketGetVolume
|
||||
WHERE routeFk = vRoute
|
||||
) v ON v.routeFk = r.id
|
||||
SET r.m3 = v.m3;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,20 +1,17 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
// Check procedure from task #1514
|
||||
xdescribe('route updateVolume()', () => {
|
||||
describe('route updateVolume()', () => {
|
||||
const routeId = 1;
|
||||
const workerFk = 9;
|
||||
const ctx = {req: {accessToken: {userId: workerFk}}};
|
||||
let originalRoute;
|
||||
let firstUpdatedTicket;
|
||||
let secondUpdatedTicket;
|
||||
let ticketRestore;
|
||||
let logIdToDestroy;
|
||||
|
||||
|
||||
afterAll(async done => {
|
||||
// await originalRoute.updateAttributes({m3: 0.2});
|
||||
// await firstUpdatedTicket.updateAttributes({routeFk: 4});
|
||||
// await secondUpdatedTicket.updateAttributes({routeFk: 4});
|
||||
await originalRoute.updateAttributes({m3: 0.2});
|
||||
await ticketRestore.updateAttributes({routeFk: 4});
|
||||
await app.models.RouteLog.destroyById(logIdToDestroy);
|
||||
done();
|
||||
});
|
||||
|
@ -26,11 +23,10 @@ xdescribe('route updateVolume()', () => {
|
|||
});
|
||||
|
||||
it('should confirm the route volume is updated when a ticket is added', async() => {
|
||||
// firstUpdatedTicket = await app.models.Ticket.findById(16);
|
||||
secondUpdatedTicket = await app.models.Ticket.findById(8);
|
||||
ticketRestore = await app.models.Ticket.findById(8);
|
||||
let updatedTicket = await app.models.Ticket.findById(8);
|
||||
|
||||
// await firstUpdatedTicket.updateAttributes({routeFk: routeId});
|
||||
await secondUpdatedTicket.updateAttributes({routeFk: routeId});
|
||||
await updatedTicket.updateAttributes({routeFk: routeId});
|
||||
await app.models.Route.updateVolume(ctx, routeId);
|
||||
|
||||
let updatedRoute = await app.models.Route.findById(routeId);
|
||||
|
|
Loading…
Reference in New Issue