Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

filter out keys that does not end with a timestamp

Carl-Gerhard Lindesvärdf1fc54e23aae
diff --git a/packages/queue/src/utils.ts b/packages/queue/src/utils.ts
index 33c675eb2..c9e0b23fb 100644
--- a/packages/queue/src/utils.ts
+++ b/packages/queue/src/utils.ts
@@ -5,13 +5,14 @@ export async function findJobByPrefix<T>(
keys: string[],
matcher: string
) {
- const filtered = keys.filter((key) => key.includes(matcher));
const getTime = (val?: string) => {
if (!val) return null;
const match = val.match(/:(\d+)$/);
return match?.[1] ? parseInt(match[1], 10) : null;
};
-
+ const filtered = keys
+ .filter((key) => key.includes(matcher))
+ .filter((key) => getTime(key));
filtered.sort((a, b) => {
const aTime = getTime(a);
const bTime = getTime(b);