feat: support sorted set queues (#177)

* feat: support sorted set queues

* fix: tune tests for queue
This commit is contained in:
Anton Voylenko
2023-06-06 23:14:38 +03:00
committed by GitHub
parent f3d3afee73
commit 32ff023b14
6 changed files with 17 additions and 17 deletions

4
app.js
View File

@@ -33,7 +33,7 @@ const {
retrieveCall,
deleteCall,
listCalls,
listQueues,
listSortedSets,
purgeCalls,
retrieveSet,
addKey,
@@ -78,7 +78,7 @@ app.locals = {
retrieveCall,
deleteCall,
listCalls,
listQueues,
listSortedSets,
purgeCalls,
retrieveSet,
addKey,

View File

@@ -4,7 +4,7 @@ const {
retrieveCall,
deleteCall,
listCalls,
listQueues,
listSortedSets,
purgeCalls,
retrieveSet,
addKey,
@@ -21,7 +21,7 @@ module.exports = {
retrieveCall,
deleteCall,
listCalls,
listQueues,
listSortedSets,
purgeCalls,
retrieveSet,
addKey,

View File

@@ -896,12 +896,12 @@ router.post('/:sid/Messages', async(req, res) => {
* retrieve info for a group of queues under an account
*/
router.get('/:sid/Queues', async(req, res) => {
const {logger, listQueues} = req.app.locals;
const {logger, listSortedSets} = req.app.locals;
const { search } = req.query || {};
try {
const accountSid = parseAccountSid(req);
await validateRequest(req, accountSid);
const queues = search ? await listQueues(accountSid, search) : await listQueues(accountSid);
const queues = search ? await listSortedSets(accountSid, search) : await listSortedSets(accountSid);
logger.debug(`retrieved ${queues.length} queues for account sid ${accountSid}`);
res.status(200).json(queues);
updateLastUsed(logger, accountSid, req).catch((err) => {});

14
package-lock.json generated
View File

@@ -13,7 +13,7 @@
"@deepgram/sdk": "^1.10.2",
"@google-cloud/speech": "^5.1.0",
"@jambonz/db-helpers": "^0.9.0",
"@jambonz/realtimedb-helpers": "^0.8.1",
"@jambonz/realtimedb-helpers": "^0.8.6",
"@jambonz/speech-utils": "^0.0.14",
"@jambonz/time-series": "^0.2.5",
"@jambonz/verb-specifications": "^0.0.21",
@@ -1790,9 +1790,9 @@
}
},
"node_modules/@jambonz/realtimedb-helpers": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.1.tgz",
"integrity": "sha512-SkF5+raJdSfzAdg82jvbQp11ioXrt1Dn456Urf/01y/Zp8jbAZKbiztxoh13lZ5Dvo6XjOuWNJVZQIIYVy0+aA==",
"version": "0.8.6",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.6.tgz",
"integrity": "sha512-ODKVVat2VAQheY13DjiAxiBBOmffMoeu3xviTjsTODr3ySZkqQZvSWU7N80pAIZvoiWG1UUEy9yI8D8mE4Jgiw==",
"dependencies": {
"debug": "^4.3.4",
"ioredis": "^5.3.2"
@@ -10358,9 +10358,9 @@
}
},
"@jambonz/realtimedb-helpers": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.1.tgz",
"integrity": "sha512-SkF5+raJdSfzAdg82jvbQp11ioXrt1Dn456Urf/01y/Zp8jbAZKbiztxoh13lZ5Dvo6XjOuWNJVZQIIYVy0+aA==",
"version": "0.8.6",
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.6.tgz",
"integrity": "sha512-ODKVVat2VAQheY13DjiAxiBBOmffMoeu3xviTjsTODr3ySZkqQZvSWU7N80pAIZvoiWG1UUEy9yI8D8mE4Jgiw==",
"requires": {
"debug": "^4.3.4",
"ioredis": "^5.3.2"

View File

@@ -23,7 +23,7 @@
"@deepgram/sdk": "^1.10.2",
"@google-cloud/speech": "^5.1.0",
"@jambonz/db-helpers": "^0.9.0",
"@jambonz/realtimedb-helpers": "^0.8.1",
"@jambonz/realtimedb-helpers": "^0.8.6",
"@jambonz/speech-utils": "^0.0.14",
"@jambonz/time-series": "^0.2.5",
"@jambonz/verb-specifications": "^0.0.21",

View File

@@ -14,7 +14,7 @@ const {
createPhoneNumber,
deleteObjectBySid} = require('./utils');
const logger = require('../lib/logger');
const { pushBack } = require('@jambonz/realtimedb-helpers')({
const { addToSortedSet } = require('@jambonz/realtimedb-helpers')({
host: process.env.JAMBONES_REDIS_HOST,
port: process.env.JAMBONES_REDIS_PORT || 6379
}, logger);
@@ -268,8 +268,8 @@ test('account tests', async(t) => {
t.ok(result.statusCode === 204, 'successfully deleted a call session limit for an account');
/* query account queues */
await pushBack(`queue:${sid}:test`, 'url1');
await pushBack(`queue:${sid}:dummy`, 'url2');
await addToSortedSet(`queue:${sid}:test`, 'url1');
await addToSortedSet(`queue:${sid}:dummy`, 'url2');
result = await request.get(`/Accounts/${sid}/Queues`, {
auth: authAdmin,