Skip to content

Commit c73f163

Browse files
author
Boris
committed
refactor: change mask for double <:>
1 parent 5a04fe0 commit c73f163

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

example/src/schema/query/queueKeys.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function createQueueKeysFC(schemaComposer: SchemaComposer<any>) {
99
fields: {
1010
queueName: 'String!',
1111
prefix: 'String!',
12+
prefixMaskNorm: 'String',
1213
},
1314
})
1415
.getTypePlural(),
@@ -23,25 +24,22 @@ export function createQueueKeysFC(schemaComposer: SchemaComposer<any>) {
2324

2425
let prefixMaskNorm = prefixMask;
2526
const nameCase = prefixMaskNorm.split(':').length - 1;
26-
if (nameCase === 2) {
27-
prefixMaskNorm = prefixMaskNorm.endsWith('*')
28-
? prefixMaskNorm.substr(0, prefixMaskNorm.length - 1)
29-
: prefixMaskNorm;
27+
if (nameCase >= 2) {
28+
prefixMaskNorm = prefixMaskNorm.split(':').slice(0, 2).join(':') + ':';
3029
} else if (nameCase === 1) {
3130
prefixMaskNorm += ':';
3231
} else {
3332
prefixMaskNorm += prefixMaskNorm.endsWith('*') ? ':*:' : '*:*:';
3433
}
3534

36-
prefixMaskNorm += 'meta';
37-
38-
const keys = await connection.keys(prefixMaskNorm);
35+
const keys = await connection.keys(prefixMaskNorm + 'meta');
3936

4037
return keys.map((key) => {
4138
const parts = key.split(':');
4239
return {
4340
queueName: parts[0],
4441
prefix: parts[1],
42+
prefixMaskNorm,
4543
};
4644
});
4745
},

0 commit comments

Comments
 (0)