Files
usenet-indexer/tools/group_sizes.ts
T
Daan MeijerandClaude Opus 5.5 3737ea1542
Test and deploy / test (push) Successful in 22s
Test and deploy / deploy (push) Skipped
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>
2026-10-09 13:31:55 +02:00

37 lines
1.5 KiB
TypeScript

/**
* 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')))