HOTFIX: Trying a different tactic for updating fields
This commit is contained in:
+5
-15
@@ -526,28 +526,18 @@ const runLadderTick = (connection) => {
|
|||||||
connection.query(query, (err, results) => {
|
connection.query(query, (err, results) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
//collect the promises
|
let query = `INSERT INTO profiles (id, ladderRank) VALUES ${ results.map((record, index) => `(${record.id}, ${index})` ) } ON DUPLICATE KEY UPDATE id = VALUES(id), ladderRank = VALUES(ladderRank);`;
|
||||||
let promises = [];
|
|
||||||
|
|
||||||
//this is really inefficient
|
connection.query(query, (err) => {
|
||||||
let query = 'UPDATE profiles SET ladderRank = ? WHERE id = ?;';
|
|
||||||
for (let i = 0; i < results.length; i++) {
|
|
||||||
promises.push(
|
|
||||||
connection.query(query, [i, results[i].id], (err) => {
|
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.all(promises)
|
log('runLadderTick completed');
|
||||||
.then((e) => log('runLadderTick completed'))
|
});
|
||||||
.catch((e) => log('runLadderTick failed', e ))
|
|
||||||
;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ladderTickJob.start();
|
ladderTickJob.start();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Reference in New Issue
Block a user