refactor(ticketTracking.userFk): refs #6398 workerFk to userFk
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
David Domenech 2023-11-30 14:25:00 +01:00
parent 4a62588464
commit 8ab981907d
12 changed files with 1201 additions and 42 deletions

View File

@ -0,0 +1 @@
ALTER TABLE `vn`.`ticketTracking` CHANGE `workerFk` `userFk` int(10) unsigned DEFAULT NULL NULL;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`ticketState`
AS SELECT `tt`.`created` AS `updated`,
`tt`.`stateFk` AS `stateFk`,
`tt`.`userFk` AS `userFk`,
`tls`.`ticketFk` AS `ticketFk`,
`s`.`id` AS `state`,
`s`.`order` AS `productionOrder`,
`s`.`alertLevel` AS `alertLevel`,
`s`.`code` AS `code`,
`tls`.`ticketFk` AS `ticket`,
`tt`.`userFk` AS `worker`,
`s`.`isPreviousPreparable` AS `isPreviousPreparable`,
`s`.`isPicked` AS `isPicked`
FROM (
(
`vn`.`ticketLastState` `tls`
JOIN `vn`.`ticketTracking` `tt` ON(`tt`.`id` = `tls`.`ticketTrackingFk`)
)
JOIN `vn`.`state` `s` ON(`s`.`id` = `tt`.`stateFk`)
);
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_inter`
AS SELECT `tt`.`id` AS `inter_id`,
`tt`.`stateFk` AS `state_id`,
`tt`.`notes` AS `nota`,
`tt`.`created` AS `odbc_date`,
`tt`.`ticketFk` AS `Id_Ticket`,
`tt`.`userFk` AS `Id_Trabajador`,
`tt`.`supervisorFk` AS `Id_supervisor`
FROM `vn`.`ticketTracking` `tt`;

View File

@ -767,7 +767,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des
-- FIX for state hours on local, inter_afterInsert -- FIX for state hours on local, inter_afterInsert
-- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND); -- UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND);
INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
VALUES VALUES
(1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), (1, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
(2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)), (2, 16, 5 , DATE_ADD(util.VN_NOW(), INTERVAL -1 MONTH)),
@ -811,6 +811,7 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`,
VALUES VALUES
(1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH)); (1, 'beta-server', 'nightmare@mydomain.com', '200', DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH));
INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`)
VALUES VALUES
(1, 'Diff', 'diff'), (1, 'Diff', 'diff'),

View File

@ -123,7 +123,7 @@ module.exports = Self => {
await models.TicketTracking.create({ await models.TicketTracking.create({
ticketFk: newRefundTicket.id, ticketFk: newRefundTicket.id,
stateFk: state.id, stateFk: state.id,
workerFk: worker.id userFk: worker.id
}, myOptions); }, myOptions);
const salesToRefund = await models.ClaimBeginning.find(salesFilter, myOptions); const salesToRefund = await models.ClaimBeginning.find(salesFilter, myOptions);

View File

@ -94,10 +94,10 @@ describe('ticket state()', () => {
const ticketTracking = await models.Ticket.state(ctx, params, options); const ticketTracking = await models.Ticket.state(ctx, params, options);
expect(ticketTracking.__data.ticketFk).toBe(params.ticketFk); expect(ticketTracking.ticketFk).toBe(params.ticketFk);
expect(ticketTracking.__data.stateFk).toBe(params.stateFk); expect(ticketTracking.stateFk).toBe(params.stateFk);
expect(ticketTracking.__data.workerFk).toBe(49); expect(ticketTracking.userFk).toBe(49);
expect(ticketTracking.__data.id).toBeDefined(); expect(ticketTracking.id).toBeDefined();
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -116,14 +116,14 @@ describe('ticket state()', () => {
const ticket = await models.Ticket.create(sampleTicket, options); const ticket = await models.Ticket.create(sampleTicket, options);
const ctx = {req: {accessToken: {userId: 18}}}; const ctx = {req: {accessToken: {userId: 18}}};
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options); const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
const params = {ticketFk: ticket.id, stateFk: assignedState.id, workerFk: 1}; const params = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
const res = await models.Ticket.state(ctx, params, options); const res = await models.Ticket.state(ctx, params, options);
expect(res.__data.ticketFk).toBe(params.ticketFk); expect(res.ticketFk).toBe(params.ticketFk);
expect(res.__data.stateFk).toBe(params.stateFk); expect(res.stateFk).toBe(params.stateFk);
expect(res.__data.workerFk).toBe(params.workerFk); expect(res.userFk).toBe(params.userFk);
expect(res.__data.workerFk).toBe(1); expect(res.userFk).toBe(1);
expect(res.__data.id).toBeDefined(); expect(res.id).toBeDefined();
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -51,12 +51,12 @@ module.exports = Self => {
params.stateFk = state.id; params.stateFk = state.id;
} }
if (!params.workerFk) { if (!params.userFk) {
const worker = await models.Worker.findOne({ const worker = await models.Worker.findOne({
where: {id: userId} where: {id: userId}
}, myOptions); }, myOptions);
params.workerFk = worker.id; params.userFk = worker.id;
} }
const ticketState = await models.TicketState.findById(params.ticketFk, { const ticketState = await models.TicketState.findById(params.ticketFk, {

View File

@ -33,10 +33,10 @@
"model": "State", "model": "State",
"foreignKey": "stateFk" "foreignKey": "stateFk"
}, },
"worker": { "user": {
"type": "belongsTo", "type": "belongsTo",
"model": "Worker", "model": "VnUser",
"foreignKey": "workerFk" "foreignKey": "userFk"
} }
} }
} }

View File

@ -2,5 +2,5 @@ module.exports = function(Self) {
require('../methods/ticket-tracking/setDelivered')(Self); require('../methods/ticket-tracking/setDelivered')(Self);
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'}); Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
Self.validatesPresenceOf('workerFk', {message: 'Worker cannot be blank'}); Self.validatesPresenceOf('userFk', {message: 'Worker cannot be blank'});
}; };

View File

@ -21,7 +21,7 @@
"stateFk": { "stateFk": {
"type": "number" "type": "number"
}, },
"workerFk": { "userFk": {
"type": "number" "type": "number"
} }
}, },
@ -36,10 +36,10 @@
"model": "State", "model": "State",
"foreignKey": "stateFk" "foreignKey": "stateFk"
}, },
"worker": { "user": {
"type": "belongsTo", "type": "belongsTo",
"model": "Worker", "model": "VnUser",
"foreignKey": "workerFk" "foreignKey": "userFk"
} }
} }
} }

View File

@ -7,16 +7,10 @@ class Controller extends Section {
this.filter = { this.filter = {
include: [ include: [
{ {
relation: 'worker',
scope: {
fields: ['id'],
include: {
relation: 'user', relation: 'user',
scope: { scope: {
fields: ['name'] fields: ['name']
} }
}
}
}, { }, {
relation: 'state', relation: 'state',
scope: { scope: {

View File

@ -64,7 +64,7 @@ module.exports = Self => {
promises.push(models.TicketTracking.create({ promises.push(models.TicketTracking.create({
ticketFk: ticket.id, ticketFk: ticket.id,
stateFk: fixingState.id, stateFk: fixingState.id,
workerFk: worker.id userFk: worker.id
}, myOptions)); }, myOptions));
} }
} }