fix pagination query offset, and also change order by transaction_id from nothing (ASC) to DESC

This commit is contained in:
Suhaimi Amir
2017-07-02 00:19:39 +08:00
parent d92492b731
commit a0e6a6e325
+2 -2
View File
@@ -423,9 +423,9 @@ app.get('/pool/payments/:pool_type', function (req, res) {
return res.json({'error': 'Invalid pool type'});
}
let paymentIds = [];
let query = "SELECT distinct(transaction_id) as txnID FROM payments WHERE pool_type = ? ORDER BY transaction_id LIMIT ? OFFSET ?";
let query = "SELECT distinct(transaction_id) as txnID FROM payments WHERE pool_type = ? ORDER BY transaction_id DESC LIMIT ? OFFSET ?";
let response = [];
global.mysql.query(query, [pool_type, limit, page]).then(function (rows) {
global.mysql.query(query, [pool_type, limit, page * limit]).then(function (rows) {
if (rows.length === 0) {
return res.json([]);
}