Skip to content

Add discover-orgs script: pre-record prominent orgs for backfill#117

Closed
peetzweg wants to merge 1 commit into
mainfrom
feature-discover-orgs
Closed

Add discover-orgs script: pre-record prominent orgs for backfill#117
peetzweg wants to merge 1 commit into
mainfrom
feature-discover-orgs

Conversation

@peetzweg

Copy link
Copy Markdown
Owner

A companion to backfill-orgs.ts for prefilling the DB with more organizations to look up.

The catch (answering "can we fetch orgs by member count?"): GitHub has no endpoint that ranks orgs by public-member count — the Search API returns only login/id, caps at 1,000 results, and can't sort or filter by members. So we can't ask for "biggest orgs" directly.

How: search type:org sorted by followers (the best prominence proxy — sorting by repos returns education/spam orgs), then enrich each candidate with fetchOrgProfile to get its actual public member count, sort/filter by that, and record the survivors as entities rows (kind='org', builtAt null). backfill-orgs.ts then fills them.

Kept as its own script on purpose. Flags: --limit (max 1000), --min-members, --query, --dry-run. Skips already-tracked orgs; idempotent upsert; paced under the search (30/min) and GraphQL (5k/hr, 500 floor) limits. Needs the read:org token, so run with env -u GITHUB_TOKEN.

env -u GITHUB_TOKEN bun scripts/discover-orgs.ts --min-members 25 --limit 300
env -u GITHUB_TOKEN bun scripts/backfill-orgs.ts        # fills what discovery recorded

Verified with a read-only --dry-run: returns real member counts, most-first, and skips known orgs.

Prefills the DB with more organizations to look up. GitHub has no endpoint that
ranks orgs by public-member count, so this searches type:org by followers (the
best prominence proxy — repos-sort returns education/spam orgs), enriches each
candidate with fetchOrgProfile to get its real public member count, sorts/filters
by that, and records the survivors as entities rows (kind='org', builtAt null).
backfill-orgs.ts then fills them.

Separate from backfill-orgs.ts by design. --limit / --min-members / --query /
--dry-run flags; skips already-tracked orgs; idempotent upsert; paced under the
search (30/min) and GraphQL (5k/hr, 500 floor) limits.
@peetzweg

Copy link
Copy Markdown
Owner Author

Folded into #104 so both org scripts live in one PR, side by side, to test and merge together. Branch feature-discover-orgs merged into feature-backfill-orgs.

@peetzweg peetzweg closed this Jul 10, 2026
@peetzweg peetzweg deleted the feature-discover-orgs branch July 10, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant