perf(revenue): server-render the promotion link and stop settling on reads #37

Merged
kate522 merged 1 commits from worktree-revenue-card-rework into main 2026-09-27 15:36:27 +00:00
Owner

Opening the 推广收益 tab was slow because every read path ran settlement
and two COUNT aggregates before the browser could show the link.

  • profile-revenue.php: the link input now carries a server-rendered value from
    ReferralAttribution::create_link(), so 复制链接 works on first paint instead
    of after a REST round trip
  • CommissionLedger::overview() no longer calls lazy_settle_due(); the
    lazy-settlement hook and its static flag are gone. Settlement runs only on
    the existing hourly aksrt_affiliate_settle_due cron, which uses a larger
    batch (100 vs 20) and would otherwise re-run up to 20 locked
    SELECT..FOR UPDATE + write cycles inside a GET request
  • ReferralAttribution::rest_me() drops the lazy_settle_due() call and the
    stats() result; stats() itself is deleted — its two COUNTs (one of them
    COUNT(DISTINCT source_user_id)) had no consumer left once the 推广人数 row
    was removed
  • credits.js: reads the link from the already-rendered input and only fetches
    /revenue/me for poster config and commission ratio. A failed fetch no longer
    blocks copying — it silently skips the poster enhancement
  • tests: the lazy-settlement contract is inverted to assert the read path stays
    read-only and cron stays wired; new assertions pin the server-rendered value
    and the no-COUNT REST payload

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

Opening the 推广收益 tab was slow because every read path ran settlement and two COUNT aggregates before the browser could show the link. - profile-revenue.php: the link input now carries a server-rendered value from ReferralAttribution::create_link(), so 复制链接 works on first paint instead of after a REST round trip - CommissionLedger::overview() no longer calls lazy_settle_due(); the lazy-settlement hook and its static flag are gone. Settlement runs only on the existing hourly aksrt_affiliate_settle_due cron, which uses a larger batch (100 vs 20) and would otherwise re-run up to 20 locked SELECT..FOR UPDATE + write cycles inside a GET request - ReferralAttribution::rest_me() drops the lazy_settle_due() call and the stats() result; stats() itself is deleted — its two COUNTs (one of them COUNT(DISTINCT source_user_id)) had no consumer left once the 推广人数 row was removed - credits.js: reads the link from the already-rendered input and only fetches /revenue/me for poster config and commission ratio. A failed fetch no longer blocks copying — it silently skips the poster enhancement - tests: the lazy-settlement contract is inverted to assert the read path stays read-only and cron stays wired; new assertions pin the server-rendered value and the no-COUNT REST payload Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kate522 added 1 commit 2026-09-27 15:36:21 +00:00
Opening the 推广收益 tab was slow because every read path ran settlement
and two COUNT aggregates before the browser could show the link.

- profile-revenue.php: the link input now carries a server-rendered value from
  ReferralAttribution::create_link(), so 复制链接 works on first paint instead
  of after a REST round trip
- CommissionLedger::overview() no longer calls lazy_settle_due(); the
  lazy-settlement hook and its static flag are gone. Settlement runs only on
  the existing hourly aksrt_affiliate_settle_due cron, which uses a larger
  batch (100 vs 20) and would otherwise re-run up to 20 locked
  SELECT..FOR UPDATE + write cycles inside a GET request
- ReferralAttribution::rest_me() drops the lazy_settle_due() call and the
  stats() result; stats() itself is deleted — its two COUNTs (one of them
  COUNT(DISTINCT source_user_id)) had no consumer left once the 推广人数 row
  was removed
- credits.js: reads the link from the already-rendered input and only fetches
  /revenue/me for poster config and commission ratio. A failed fetch no longer
  blocks copying — it silently skips the poster enhancement
- tests: the lazy-settlement contract is inverted to assert the read path stays
  read-only and cron stays wired; new assertions pin the server-rendered value
  and the no-COUNT REST payload

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kate522 merged commit 1355a9244f into main 2026-09-27 15:36:27 +00:00
kate522 deleted branch worktree-revenue-card-rework 2026-09-27 15:36:27 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kate522/wordpress-theme-aksrt#37