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) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const jobs = await this.deliverQueue.getJobs(['delayed']);
|
const jobs = await this.deliverQueue.getJobs(['delayed']);
|
||||||
|
|
||||||
const res = [] as [string, number][];
|
const res = new Map<string, number>();
|
||||||
|
|
||||||
for (const job of jobs) {
|
for (const job of jobs) {
|
||||||
let host: string;
|
let host: string;
|
||||||
@ -68,17 +68,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const found = res.find(x => x[0] === host);
|
const found = res.get(host);
|
||||||
if (found) {
|
if (found) {
|
||||||
found[1]++;
|
res.set(host, found + 1);
|
||||||
} else {
|
} else {
|
||||||
res.push([host, 1]);
|
res.set(host, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.sort((a, b) => b[1] - a[1]);
|
return Array.from(res.entries()).sort((a, b) => b[1] - a[1]);
|
||||||
|
|
||||||
return res;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const jobs = await this.inboxQueue.getJobs(['delayed']);
|
const jobs = await this.inboxQueue.getJobs(['delayed']);
|
||||||
|
|
||||||
const res = [] as [string, number][];
|
const res = new Map<string, number>();
|
||||||
|
|
||||||
for (const job of jobs) {
|
for (const job of jobs) {
|
||||||
let host: string;
|
let host: string;
|
||||||
@ -68,17 +68,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const found = res.find(x => x[0] === host);
|
const found = res.get(host);
|
||||||
if (found) {
|
if (found) {
|
||||||
found[1]++;
|
res.set(host, found + 1);
|
||||||
} else {
|
} else {
|
||||||
res.push([host, 1]);
|
res.set(host, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.sort((a, b) => b[1] - a[1]);
|
return Array.from(res.entries()).sort((a, b) => b[1] - a[1]);
|
||||||
|
|
||||||
return res;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user