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');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
// Check procedure from task #1514
|
describe('route updateVolume()', () => {
|
||||||
xdescribe('route updateVolume()', () => {
|
|
||||||
const routeId = 1;
|
const routeId = 1;
|
||||||
const workerFk = 9;
|
const workerFk = 9;
|
||||||
const ctx = {req: {accessToken: {userId: workerFk}}};
|
const ctx = {req: {accessToken: {userId: workerFk}}};
|
||||||
let originalRoute;
|
let originalRoute;
|
||||||
let firstUpdatedTicket;
|
let ticketRestore;
|
||||||
let secondUpdatedTicket;
|
|
||||||
let logIdToDestroy;
|
let logIdToDestroy;
|
||||||
|
|
||||||
|
|
||||||
afterAll(async done => {
|
afterAll(async done => {
|
||||||
// await originalRoute.updateAttributes({m3: 0.2});
|
await originalRoute.updateAttributes({m3: 0.2});
|
||||||
// await firstUpdatedTicket.updateAttributes({routeFk: 4});
|
await ticketRestore.updateAttributes({routeFk: 4});
|
||||||
// await secondUpdatedTicket.updateAttributes({routeFk: 4});
|
|
||||||
await app.models.RouteLog.destroyById(logIdToDestroy);
|
await app.models.RouteLog.destroyById(logIdToDestroy);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -26,11 +23,10 @@ xdescribe('route updateVolume()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should confirm the route volume is updated when a ticket is added', async() => {
|
it('should confirm the route volume is updated when a ticket is added', async() => {
|
||||||
// firstUpdatedTicket = await app.models.Ticket.findById(16);
|
ticketRestore = await app.models.Ticket.findById(8);
|
||||||
secondUpdatedTicket = await app.models.Ticket.findById(8);
|
let updatedTicket = await app.models.Ticket.findById(8);
|
||||||
|
|
||||||
// await firstUpdatedTicket.updateAttributes({routeFk: routeId});
|
await updatedTicket.updateAttributes({routeFk: routeId});
|
||||||
await secondUpdatedTicket.updateAttributes({routeFk: routeId});
|
|
||||||
await app.models.Route.updateVolume(ctx, routeId);
|
await app.models.Route.updateVolume(ctx, routeId);
|
||||||
|
|
||||||
let updatedRoute = await app.models.Route.findById(routeId);
|
let updatedRoute = await app.models.Route.findById(routeId);
|
||||||
|
|
Loading…
Reference in New Issue