Skip to content

Reuse account page summary context#888

Open
xiefuzheng713-alt wants to merge 1 commit into
ramimbo:mainfrom
xiefuzheng713-alt:codex/next-cleanup-846
Open

Reuse account page summary context#888
xiefuzheng713-alt wants to merge 1 commit into
ramimbo:mainfrom
xiefuzheng713-alt:codex/next-cleanup-846

Conversation

@xiefuzheng713-alt
Copy link
Copy Markdown
Contributor

@xiefuzheng713-alt xiefuzheng713-alt commented Jun 4, 2026

Refs #846

Summary

  • Add an internal account API context helper for already-normalized account ids.
  • Reuse that account context from the account page so accepted/pending summaries are built once and shared with the rendered page context.
  • Add regression coverage that the page summary fields reuse the API context values while preserving account normalization.

Duplicate check

  • Searched open PRs for account page summary/context reuse, accepted_summary, pending_summary, and accounts.py overlap.
  • Existing open PRs cover account row limits, query validation, or activity/account filters, not account page summary context reuse.

Validation

  • uv run --python 3.12 --extra dev python -m pytest tests/test_account_routes.py tests/test_account_validation.py -q -> 52 passed, 1 existing Starlette/httpx warning.
  • uv run --python 3.12 --extra dev ruff check . -> passed.
  • uv run --python 3.12 --extra dev ruff format --check . -> 111 files already formatted.
  • uv run --python 3.12 --extra dev mypy app -> success across 42 source files.
  • uv run --python 3.12 --extra dev python scripts/docs_smoke.py -> docs smoke ok.
  • git diff --check origin/main...HEAD -> clean.
  • git merge-tree --write-tree origin/main HEAD -> clean tree 4af20c2477f9b25e51a0780c138a38dd3e15a3b7.

Scope

Account page/API context maintainability only. No ledger mutation, wallet registration, transfer signing, payout/proof execution, treasury/proposal mutation, admin-token API, exchange, bridge, cash-out, MRWK price behavior, private data, or secrets behavior changed.

Summary by CodeRabbit

  • Refactor

    • Improved internal code organization and efficiency by consolidating account context computation logic.
  • Tests

    • Added test coverage to verify consistency of internal context reuse patterns.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eb3d3491-8da0-48e9-8d77-8f2cf0b79e95

📥 Commits

Reviewing files that changed from the base of the PR and between d4d0e48 and 635115e.

📒 Files selected for processing (2)
  • app/accounts.py
  • tests/test_account_routes.py

📝 Walkthrough

Walkthrough

This PR refactors account context computation by extracting core logic into a reusable helper, then updates account_page_context to consume that helper instead of duplicating summary and payout calculations. A new test validates the reuse pattern.

Changes

Account Context Extraction and Reuse

Layer / File(s) Summary
Helper extraction and public API refactoring
app/accounts.py
New internal _account_api_context_for_normalized_account helper builds context for an already-normalized account. The public account_api_context now normalizes the input and delegates to this helper.
Page context reuse of helper output
app/accounts.py
account_page_context calls the helper once and pulls accepted_summary, pending_summary, and pending_payouts from that precomputed result, eliminating prior duplicate computation.
Test for context reuse behavior
tests/test_account_routes.py
Imports add app.accounts module alias and type support. New test monkeypatches summary helpers to count invocations and asserts that page context reuses the helper-derived summary and payout fields.

Possibly related PRs

  • ramimbo/mergework#730: Both PRs modify account_api_context and account_page_context to wire and reuse pending_summary and pending_payouts.
  • ramimbo/mergework#388: Prior PR that introduced the extracted account_api_context and account_page_context structure that this PR refactors further.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Reuse account page summary context' clearly and concretely names the main changed surface—reusing context between account page and API—matching the core refactoring described in the changeset.
Description check ✅ Passed The description covers all required template sections with substantive content: clear summary of changes, duplicate/PR search evidence, comprehensive validation results across all tooling, and explicit scope boundaries.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Mergework Public Artifact Hygiene ✅ Passed PR is a technical refactoring with no investment, price, cash-out, fabricated payout claims, or security details. Code changes are internal; no new public documentation or problematic claims added.
Bounty Pr Focus ✅ Passed PR #888 does not reference a "Bounty #N" or "Refs #N" per the check's conditional scope; check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@mauricemohr88-debug mauricemohr88-debug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 635115ec07ccf21463c91c2426449a79955f6ac3.

Approved. I inspected app/accounts.py and tests/test_account_routes.py and verified this is a focused account-context reuse refactor:

  • _account_api_context_for_normalized_account() extracts the prior account_api_context() body for already-normalized account ids;
  • public account_api_context() still normalizes the incoming account before delegating, preserving external behavior;
  • account_page_context() now reuses the helper output for accepted_summary, pending_summary, and pending_payouts, while still building accepted work and ledger transaction rows separately;
  • the new regression test monkeypatches the safe summary/pending helpers and confirms the page context reuses the helper-derived values exactly once while preserving account normalization;
  • no ledger mutation, wallet registration, transfer signing, payout/proof execution, treasury/proposal mutation, admin-token API, bridge, exchange, cash-out, MRWK price, private-data, credential, or secret-handling behavior is changed.

Validation on this exact head:

  • uv run --python 3.12 --extra dev python -m pytest tests/test_account_routes.py tests/test_account_validation.py -q -> 52 passed, 1 existing Starlette/httpx warning.
  • uv run --python 3.12 --extra dev ruff check app/accounts.py tests/test_account_routes.py tests/test_account_validation.py -> passed.
  • uv run --python 3.12 --extra dev ruff format --check app/accounts.py tests/test_account_routes.py tests/test_account_validation.py -> 3 files already formatted.
  • uv run --python 3.12 --extra dev mypy app/accounts.py -> success.
  • uv run --python 3.12 --extra dev python scripts/docs_smoke.py -> docs smoke ok.
  • git diff --check origin/main...HEAD -> clean.
  • git merge-tree --write-tree origin/main HEAD -> clean tree 4af20c2477f9b25e51a0780c138a38dd3e15a3b7.

GitHub state checked before approval: mergeStateStatus=CLEAN; hosted Quality, readiness, docs, and image checks and CodeRabbit statuses are successful on this head. I found no prior human review and no existing #838 claim for PR #888 / this head before posting this review.

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.

2 participants