Skip to content

Add Ahrefs Domain Rating to the ad network directory - #131

Merged
RaviTejaKNTS merged 1 commit into
mainfrom
ad-network-domain-rating
Nov 14, 2026
Merged

RaviTejaKNTS merged 1 commit into
mainfrom
ad-network-domain-rating

Conversation

@RaviTejaKNTS

Copy link
Copy Markdown
Collaborator

What

  • Collection: new OVH job domain-rating (scripts/ad-networks/domain-rating.mjs) fetches Ahrefs Domain Rating for ad network publisher sites from the free endpoint.
    • Order: managed sites first, then other listed sites, then everyone else, then the oldest checks after 30 days.
    • Schedule: cron 5 7-23 * * *, 500 domains, 30-minute budget, at least 3 seconds between requests.
    • Expected time: about 5 days for the 39,823 managed sites, about 26 days for all 213,003.
  • Shared Ahrefs client scripts/stack127/ahrefs-dr.mjs, used by this job and the launch-directory metrics job.
    • One process lock and crash-safe persisted pacing and cooldown at /srv/stack127-data/state/ahrefs.sqlite, so a Retry-After received by either job stops both.
  • Storage: domain_rating and domain_rating_checked_on in the SQLite store and PostgreSQL, synced in 500-row batches. DR-only writes do not move the frontend revision; the daily snapshot publishes new values.
  • Pages:
    • Domain rating block on each network page: median, average, coverage, bands, and a comparison with the big networks showing rated/total counts. Hidden below 20 rated sites or 25% coverage.
    • DR column, sorts (unrated last), and filter in the sites lists.
    • Checker row.
    • Average DR on the stats page.
  • MCP and REST: DR fields, min/max filters, bands, and per-network summaries. Merged with the brand kit tool added on main.
  • Attribution: every place that shows or returns DR, including the public /api/ad-networks/sites and /api/ad-networks/site responses, carries the linked "Domain Rating by Ahrefs" credit required by the Ahrefs license.
  • Migration: nullable columns and a named NOT VALID range check, validated in a second transaction to avoid a long lock on the 125,000-row table. Idempotent, with type guards.

Review

Three review rounds by a separate reviewer. Fixed:

  • public API attribution;
  • shared Ahrefs pacing and cooldown between the two jobs;
  • crash safety of that cooldown (four real SIGKILL tests);
  • migration locking and idempotency;
  • coverage labels on comparisons;
  • two outdated tests;
  • docs.

The final round found no issues. Rebased on main with the brand kit changes; conflicts in lib/data-api and the MCP guide were resolved by keeping both.

Checks

  • npm run quality: TypeScript and 133 tests.
  • npm run test:data-api: 19 tests.
  • Ad network tests: 476 passed, 12 skipped (database integration, opt-in).

Rollout after merge

  1. Add AHREFS_API_KEY to Infisical stack127 /vps/ad-networks.
  2. Update /srv/stack127 on OVH with both Ahrefs jobs stopped, since the lock path changed.
  3. Install the cron line, then run one manual batch and check the log.

🤖 Generated with Claude Code

A new OVH job, domain-rating, collects DR for ad network publisher
sites from Ahrefs' free endpoint: managed sites first, then other
listed sites, then the rest, then the oldest checks after 30 days. It
runs hourly (500 domains, 30-minute budget), at least 3 seconds
between requests. It shares one crash-safe pacing and cooldown state
with the launch-directory metrics job, which uses the same key, so a
Retry-After received by either stops both. DR-only writes do not move
the frontend revision; the daily snapshot publishes new values.

Pages: a Domain rating block on each network page (median, average,
coverage, bands, comparison with the big networks, hidden below 20
rated sites or 25% coverage), a DR column, sorts and filter in the
sites lists, a checker row, and average DR on the stats page. Every
place that shows or returns DR, including the public JSON APIs and the
private MCP and REST, carries the linked "Domain Rating by Ahrefs"
credit, as the Ahrefs license requires.

The migration adds nullable columns and a NOT VALID range check, then
validates it in a second transaction to avoid a long table lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RaviTejaKNTS
RaviTejaKNTS merged commit 626b83c into main Nov 14, 2026
7 of 8 checks passed

This branch was previously deployed

1 inactive deployment
production — fd0227d5 Deployed Nov 14, 2026 by RaviTejaKNTS via verify-production-build #123
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