Rebuild: tools to rank groups by real span (GROUP's low) and sample how full they are
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0613984de9
commit
3737ea1542
3 files changed
+89
No files matched your search
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Every group matching a pattern with its real span: LIST ACTIVE for the
|
||||
* names (its low is always 2 on Eweka), GROUP per group for the real low and
|
||||
* count. TSV, largest span first: rank, name, low, high, span, count.
|
||||
*
|
||||
* node --env-file=.env --import=@poppinss/ts-exec tools/group_sizes.ts 'alt.binaries.*' [connections] > groups.tsv
|
||||
*/
|
||||
import { XoverClient } from '#lib/nntp/index'
|
||||
|
||||
const pattern = process.argv[2] ?? 'alt.binaries.*'
|
||||
const connections = Number(process.argv[3] ?? 4)
|
||||
const env = process.env
|
||||
const connect = () =>
|
||||
XoverClient.connect({ host: env.NNTP_HOST!, port: Number(env.NNTP_PORT ?? 563), user: env.NNTP_USER, password: env.NNTP_PASSWORD, secure: (env.NNTP_SECURE ?? 'true') !== 'false', compress: true, timeoutMs: 60_000 })
|
||||
|
||||
const first = await connect()
|
||||
const names = (await first.listActive(pattern)).map((g) => g.name)
|
||||
const queue = [...names]
|
||||
const out: { name: string; low: number; high: number; count: number }[] = []
|
||||
await Promise.all(
|
||||
Array.from({ length: connections }, async (_, i) => {
|
||||
const client = i === 0 ? first : await connect()
|
||||
while (queue.length) {
|
||||
const name = queue.shift()!
|
||||
try {
|
||||
const g = await client.group(name)
|
||||
out.push({ name, ...g })
|
||||
} catch (error: any) {
|
||||
console.error(`${name}: ${error.message}`)
|
||||
}
|
||||
}
|
||||
client.close()
|
||||
})
|
||||
)
|
||||
out.sort((a, b) => b.high - b.low - (a.high - a.low))
|
||||
out.forEach((g, i) => console.log([i + 1, g.name, g.low, g.high, g.high - g.low, g.count].join('\t')))
|
||||
Reference in new issue
Block a user