fix: refs #7906 optimize method fix
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
e06c744fb3
commit
f53998f320
|
@ -45,18 +45,33 @@ module.exports = Self => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
console.time('finds');
|
||||||
const [ticketList, fixingState, worker] = await Promise.all([
|
const [ticketList, fixingState, worker] = await Promise.all([
|
||||||
models.Ticket.find(filter, myOptions),
|
models.Ticket.find(filter, myOptions),
|
||||||
models.State.findOne({where: {code: 'FIXING'}}, myOptions),
|
models.State.findOne({where: {code: 'FIXING'}}, myOptions),
|
||||||
models.Worker.findOne({where: {id: userId}}, myOptions)
|
models.Worker.findOne({where: {id: userId}}, myOptions)
|
||||||
]);
|
]);
|
||||||
|
console.timeEnd('finds');
|
||||||
|
|
||||||
await models.Ticket.rawSql(
|
console.time('ticket update');
|
||||||
'UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ?',
|
console.log('ticketList: ', ticketList.length);
|
||||||
[id],
|
// await models.Ticket.rawSql(
|
||||||
myOptions
|
// 'UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ? LIMIT 2000',
|
||||||
);
|
// [id],
|
||||||
|
// myOptions
|
||||||
|
// );
|
||||||
|
const promises = [];
|
||||||
|
// OFFSET no li mola a mariadb
|
||||||
|
for (let i = 0; i <= 30000; i += 2000) {
|
||||||
|
promises.push(models.Ticket.rawSql(
|
||||||
|
`UPDATE ticket SET zoneFk = NULL WHERE zoneFk = ? LIMIT 2000 OFFSET ${i};`,
|
||||||
|
[id],
|
||||||
|
myOptions
|
||||||
|
));
|
||||||
|
}
|
||||||
|
await Promise.all(promises);
|
||||||
|
console.timeEnd('ticket update');
|
||||||
|
/*
|
||||||
|
|
||||||
const updatePromises = ticketList.map(ticket => {
|
const updatePromises = ticketList.map(ticket => {
|
||||||
if (ticket.ticketState().alertLevel === 0) {
|
if (ticket.ticketState().alertLevel === 0) {
|
||||||
|
@ -69,8 +84,8 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
await Promise.all(updatePromises);
|
await Promise.all(updatePromises);
|
||||||
await models.Zone.destroyById(id, myOptions);
|
await models.Zone.destroyById(id, myOptions);
|
||||||
|
*/
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.rollback();
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue