Skip to content

Commit

Permalink
perf(backend): queue の delayed の件数が増えた際に deliver-delayed と inbox-dela…
Browse files Browse the repository at this point in the history
…yed が返ってこなくなる問題を修正 (MisskeyIO#750)
  • Loading branch information
riku6460 authored Oct 18, 2024
1 parent 30c5aa6 commit 3fdcf99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
super(meta, paramDef, async (ps, me) => {
const jobs = await this.deliverQueue.getJobs(['delayed']);

const res = [] as [string, number][];
const res = new Map<string, number>();

for (const job of jobs) {
let host: string;
Expand All @@ -68,17 +68,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
continue;
}

const found = res.find(x => x[0] === host);
const found = res.get(host);
if (found) {
found[1]++;
res.set(host, found + 1);
} else {
res.push([host, 1]);
res.set(host, 1);
}
}

res.sort((a, b) => b[1] - a[1]);

return res;
return Array.from(res.entries()).sort((a, b) => b[1] - a[1]);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
super(meta, paramDef, async (ps, me) => {
const jobs = await this.inboxQueue.getJobs(['delayed']);

const res = [] as [string, number][];
const res = new Map<string, number>();

for (const job of jobs) {
let host: string;
Expand All @@ -68,17 +68,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
continue;
}

const found = res.find(x => x[0] === host);
const found = res.get(host);
if (found) {
found[1]++;
res.set(host, found + 1);
} else {
res.push([host, 1]);
res.set(host, 1);
}
}

res.sort((a, b) => b[1] - a[1]);

return res;
return Array.from(res.entries()).sort((a, b) => b[1] - a[1]);
});
}
}

0 comments on commit 3fdcf99

Please sign in to comment.