mirror of
https://github.com/MisskeyIO/misskey
synced 2024-11-27 14:28:49 +09:00
perf(backend): queue の delayed の件数が増えた際に deliver-delayed と inbox-delayed が返ってこなくなる問題を修正 (MisskeyIO#750)
This commit is contained in:
parent
30c5aa6b92
commit
3fdcf99011
@ -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]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user