Skip to content

Commit

Permalink
fix(ordering): Allow ordering queue listings
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jan 15, 2024
1 parent 8cf79d0 commit 777cf26
Show file tree
Hide file tree
Showing 8 changed files with 4,657 additions and 3,021 deletions.
7 changes: 7 additions & 0 deletions .ncurc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
upgrade: true,
reject: [
// mongodb 5.x driver does not support callbacks, only promises
'mongodb'
]
};
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const RedisStore = require('connect-redis')(session);
const RedisStore = require('connect-redis').default;
const flash = require('connect-flash');
const hbs = require('hbs');
const humanize = require('humanize');
Expand Down
2 changes: 1 addition & 1 deletion lib/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const yaml = require('js-yaml');
const fs = require('fs');
const log = require('npmlog');
const pathlib = require('path');
const setupIndexes = yaml.safeLoad(fs.readFileSync(pathlib.join(__dirname, '..', 'setup', 'indexes.yaml'), 'utf8'));
const setupIndexes = yaml.load(fs.readFileSync(pathlib.join(__dirname, '..', 'setup', 'indexes.yaml'), 'utf8'));
const mongodb = require('mongodb');
const Redis = require('ioredis');

Expand Down
11 changes: 9 additions & 2 deletions lib/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const config = require('wild-config');
const request = require('request');
const redis = require('./db').redis;
const URL = require('url').URL;

let lastCheck = false;
let currentSpeed = new Map();
Expand Down Expand Up @@ -151,9 +152,15 @@ function fetchZoneList(callback) {
);
}

function fetchQueued(zone, type, callback) {
function fetchQueued(zone, type, query, callback) {
const url = new URL('/queued/' + encodeURIComponent(type) + '/' + encodeURIComponent(zone), config.apiServer);

for (let key of Object.keys(query || {})) {
url.searchParams.append(key, query[key]);
}

request(
config.apiServer + '/queued/' + encodeURIComponent(type) + '/' + encodeURIComponent(zone),
url.href,
{
json: true
},
Expand Down
Loading

0 comments on commit 777cf26

Please sign in to comment.