7253-devToTest_2418 #2350

Merged
alexm merged 320 commits from 7253-devToTest_2418 into test 2024-04-23 08:02:46 +00:00
5 changed files with 12 additions and 13 deletions
Showing only changes of commit ae25ba3fb6 - Show all commits

View File

@ -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')

View File

@ -80,8 +80,6 @@ fdescribe('Operator', () => {
console.log('lastNotification: ', lastNotification);
expect(1).toEqual('Is already Notified');
await tx.rollback();
} catch (e) {
await tx.rollback();

View File

@ -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;
}

View File

@ -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

View File

@ -1,4 +0,0 @@
SELECT nq.params
FROM util.notificationQueue nq
JOIN util.notification n ON n.name = nq.notificationFk
WHERE n.name = ?