Implemented new ladder ordering algorithm

This commit is contained in:
2019-06-10 18:13:56 +10:00
parent a9017da72c
commit 3e6a00caf8
7 changed files with 78 additions and 18 deletions
+3 -3
View File
@@ -109,10 +109,10 @@ const isSpying = (connection, user, cb) => {
});
};
const getLadderData = (connection, start, length, cb) => {
const getLadderData = (connection, field, start, length, cb) => {
//moved here for reusability
let query = 'SELECT accounts.id AS id, username, soldiers, recruits, gold FROM accounts JOIN profiles ON accounts.id = profiles.accountId ORDER BY soldiers DESC, recruits DESC, gold DESC LIMIT ?, ?;';
connection.query(query, [start, length], (err, results) => {
let query = 'SELECT accounts.id AS id, username, soldiers, recruits, gold FROM accounts JOIN profiles ON accounts.id = profiles.accountId ORDER BY ? DESC LIMIT ?, ?;';
connection.query(query, [field, start, length], (err, results) => {
cb(err, results);
});
};