Skip to content

Add account filter to activity API#821

Merged
ramimbo merged 1 commit into
ramimbo:mainfrom
keilogic:codex/activity-account-filter-761
Jun 2, 2026
Merged

Add account filter to activity API#821
ramimbo merged 1 commit into
ramimbo:mainfrom
keilogic:codex/activity-account-filter-761

Conversation

@keilogic
Copy link
Copy Markdown
Contributor

@keilogic keilogic commented Jun 2, 2026

Summary

  • Adds an exact account= filter for /api/v1/activity.
  • Applies the filter to both proof-backed accepted-work activity and pending payout activity.
  • Documents the account-scoped activity query in the agent guide and API examples.

Bounty / Source

/claim #761

Source: #786 identified that /api/v1/activity?account=... was accepted but returned the global feed instead of a scoped account view.

Validation

  • python -m pytest tests/test_activity.py tests/test_activity_routes.py tests/test_docs_public_urls.py -q -> 41 passed, 1 warning
  • python -m ruff check app/activity.py app/serializers.py tests/test_activity.py tests/test_activity_routes.py tests/test_docs_public_urls.py
  • python -m ruff format --check app/activity.py app/serializers.py tests/test_activity.py tests/test_activity_routes.py tests/test_docs_public_urls.py
  • python scripts/docs_smoke.py
  • python -m mypy app/activity.py app/serializers.py
  • git diff --check origin/main...HEAD

Scope

No payout execution, treasury mutation, wallet mutation, bridge/exchange/off-ramp/cash-out behavior, price/liquidity claims, private data, secrets, or admin-token behavior changed.

Summary by CodeRabbit

  • New Features

    • The activity API endpoint now supports filtering results by an exact account using an account query parameter.
  • Documentation

    • Added examples and explanations for using the new account filter in the user and API guides.
  • Bug Fixes

    • Improved validation for the account query parameter, including control character and duplicate parameter checks.
  • Tests

    • Added comprehensive tests for activity filtering by account and input validation for the query parameter.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 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: 93030c52-8ec4-4930-8039-7cc2c5d9fb10

📥 Commits

Reviewing files that changed from the base of the PR and between 12ca2f0 and 9de63c4.

📒 Files selected for processing (5)
  • app/activity.py
  • app/serializers.py
  • docs/agent-guide.md
  • docs/api-examples.md
  • tests/test_activity.py

📝 Walkthrough

Walkthrough

The PR adds an account query parameter to /api/v1/activity to filter activity by exact account scope. The account parameter flows from the API endpoint through activity_context to serializer functions, where it filters both recent and pending activity rows; the parameter is validated alongside q and included in the response.

Changes

Account filtering for activity endpoint

Layer / File(s) Summary
Account filtering in serializers
app/serializers.py
pending_activity_rows and activity_to_dict accept a keyword-only account parameter; rows are filtered by account before query matching, and the account is included in the returned activity dictionary.
API endpoint and context integration
app/activity.py
Imports normalized_account, extends activity_context to normalize and forward the account parameter, and updates the /api/v1/activity handler to validate and forward account to activity_context.
Tests for account filtering
tests/test_activity.py
New test covers account-scoped activity filtering with paid and pending activity; extended validation test checks control characters, parameter repetition, and invalid login format for the account parameter.
Documentation updates
docs/api-examples.md, docs/agent-guide.md
Updated API examples with concrete account query usage and clarified the distinction between account (exact account scoping) and q (free-text search); agent guide example includes activity request with account filter.

Possibly related issues

  • ramimbo/mergework#786: The PR directly implements explicit account-filter handling for /api/v1/activity by adding an account parameter to activity context and serializers with validation and tests.

Possibly related PRs

  • ramimbo/mergework#733: Both PRs modify app/serializers.py activity serialization functions (pending_activity_rows and activity_to_dict) but address different filtering/output concerns.
  • ramimbo/mergework#301: Both PRs modify the activity serialization output in app/serializers.py for the recent accepted-work activity rows.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add account filter to activity API' directly and concretely names the main change across all modified files.
Description check ✅ Passed The description covers the summary, evidence (bounty/source issue), validation results, and scope. All required sections are present and substantive.
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 contains no investment, price, cash-out claims, or fabricated payouts. Documentation properly distinguishes pending from proof-backed activity with safeguard instructions.
Bounty Pr Focus ✅ Passed PR references Bounty #761; diff matches stated files (activity.py, serializers.py, docs, tests); comprehensive test coverage; no treasury/wallet/payout execution scope creep.

✏️ 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
Contributor

@yui-stingray yui-stingray 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 9de63c43ab47bd9ecd2961a674c68beddadc13b7.

No blockers found. I inspected app/activity.py, app/serializers.py, tests/test_activity.py, docs/agent-guide.md, and docs/api-examples.md. The new account query parameter is normalized before reaching the serializer, and the serializer now applies the exact account filter to both proof-backed activity rows and pending payout rows before computing totals. The existing q filter still works as a narrower search inside the account-scoped slice.

Validation I ran on the PR head:

  • pytest tests/test_activity.py tests/test_activity_routes.py tests/test_docs_public_urls.py -q --capture=no -> 41 passed, 1 warning
  • targeted ruff check and ruff format --check on the changed Python/test files -> passed
  • mypy app/activity.py app/serializers.py -> passed
  • python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> passed
  • git merge-tree --write-tree origin/main HEAD -> clean

GitHub also shows the hosted quality check and CodeRabbit status passing on this head, with no actionable CodeRabbit comments. I did not review or change payout execution, wallet material, treasury mutation, private data, exchange, bridge, cash-out, or price behavior.

@ramimbo
Copy link
Copy Markdown
Owner

ramimbo commented Jun 2, 2026

Holding this for another useful current-head non-author human review before acceptance. This changes public API behavior, so I am keeping the 2-review bar. CI and CodeRabbit are green; no mrwk:accepted or payout label has been applied.

Copy link
Copy Markdown
Contributor

@aunysillyme aunysillyme left a comment

Choose a reason for hiding this comment

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

Approved. Verified locally on commit 9de63c4. Ran unit tests (tests/test_activity.py - 7 passed, full suite - 707 passed) and verified ruff linter/formatting checks. The implementation of account-scoped filtering for activity feed and pending activity rows is clean, robust, and correctly resolves issue #786.

@ramimbo ramimbo merged commit 0a665d0 into ramimbo:main Jun 2, 2026
2 checks passed
@ramimbo ramimbo added mrwk:accepted Maintainer accepted for payout mrwk:paid Ledger payment recorded labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mrwk:accepted Maintainer accepted for payout mrwk:paid Ledger payment recorded

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants