7253-devToTest_2418 #2350
|
@ -67,7 +67,7 @@ module.exports = Self => {
|
|||
continue;
|
||||
}
|
||||
|
||||
const newParams = Object.assign({}, queueParams, sendParams);
|
||||
const newParams = Object.assign({}, queueParams, sendParams, {created: queue.created});
|
||||
const email = new Email(queueName, newParams);
|
||||
|
||||
if (process.env.NODE_ENV != 'test')
|
||||
|
|
|
@ -80,8 +80,6 @@ fdescribe('Operator', () => {
|
|||
|
||||
console.log('lastNotification: ', lastNotification);
|
||||
|
||||
expect(1).toEqual('Is already Notified');
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -5,7 +5,7 @@ const name = 'backup-printer-selected';
|
|||
module.exports = {
|
||||
name: name,
|
||||
async serverPrefetch() {
|
||||
const notifications = await this.rawSqlFromDef('previousNotifications', [name]);
|
||||
const notifications = await this.rawSqlFromDef('previousNotifications', [name, this.created, this.created]);
|
||||
if (!notifications.length || checkDuplicates(notifications, this.labelerId, this.sectorId))
|
||||
throw new Error('Previous notification sended with the same parameters');
|
||||
|
||||
|
@ -32,18 +32,21 @@ module.exports = {
|
|||
workerId: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
created: {
|
||||
type: Date,
|
||||
required: true
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function checkDuplicates(notifications, labelerFk, printerFk) {
|
||||
const criteria = {
|
||||
labelerId: labelerFk,
|
||||
sectorId: printerFk
|
||||
};
|
||||
const criteria = {labelerId: labelerFk, sectorId: printerFk};
|
||||
const filteredNotifications = notifications.filter(notification => {
|
||||
const paramsObj = JSON.parse(notification.params);
|
||||
return Object.keys(criteria).every(key => criteria[key] === paramsObj[key]);
|
||||
});
|
||||
|
||||
return filteredNotifications.length > 1;
|
||||
}
|
||||
|
|
|
@ -2,4 +2,6 @@ SELECT nq.params, created, status
|
|||
FROM util.notificationQueue nq
|
||||
JOIN util.notification n ON n.name = nq.notificationFk
|
||||
WHERE n.name = ?
|
||||
AND TIMESTAMPDIFF(SECOND, nq.created, util.VN_NOW()) <= n.delay
|
||||
AND nq.created BETWEEN ? - INTERVAL IFNULL(n.delay, 0) SECOND AND ?
|
||||
AND nq.status <> 'error'
|
||||
ORDER BY created
|
|
@ -1,4 +0,0 @@
|
|||
SELECT nq.params
|
||||
FROM util.notificationQueue nq
|
||||
JOIN util.notification n ON n.name = nq.notificationFk
|
||||
WHERE n.name = ?
|
Loading…
Reference in New Issue