perf(backend): queue の delayed の件数が増えた際に deliver-delayed と inbox-delayed が返ってこなくなる問題を修正 (MisskeyIO#750)

This commit is contained in:
riku6460 2024-10-18 22:35:33 +09:00 committed by GitHub
parent 30c5aa6b92
commit 3fdcf99011
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 14 deletions

View File

@ -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;
@ -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]);
});
}
}

View File

@ -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;
@ -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]);
});
}
}