Skip to content

docs(v4): document /v4/activity endpoint#88

Merged
escapedcat merged 1 commit into
feature/activity-places-filterfrom
docs/activity-endpoint
Apr 20, 2026
Merged

docs(v4): document /v4/activity endpoint#88
escapedcat merged 1 commit into
feature/activity-places-filterfrom
docs/activity-endpoint

Conversation

@escapedcat

Copy link
Copy Markdown
Collaborator

The activity feed endpoint was shipped without a corresponding doc (same as #86's top-editors). Adds docs/rest/v4/activity.md covering parameters (days / area / areas / places), response shape, examples, and error cases, plus a link in the v4 README under "Implemented".

Includes the ?places= parameter added in #87, so this branch should merge after that one.

The activity feed endpoint was shipped without a corresponding doc
(same as #86's top-editors). Adds docs/rest/v4/activity.md covering
parameters (days / area / areas / places), response shape, examples,
and error cases, plus a link in the v4 README under "Implemented".

Includes the `?places=` parameter added in #87, so this branch should
merge after that one.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2bf596da-c0e3-47e5-93d8-a4fb238d9acc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/activity-endpoint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@escapedcat escapedcat merged commit 4c565e3 into feature/activity-places-filter Apr 20, 2026
1 check passed
@escapedcat escapedcat deleted the docs/activity-endpoint branch April 20, 2026 07:56
escapedcat added a commit that referenced this pull request Apr 21, 2026
* feat(v4): add places filter to /v4/activity endpoint

Accepts ?places=id1,id2 alongside existing ?areas= and ?area= params.
Place IDs union with area-derived element IDs via HashSet so events
covered by both a saved area and an explicitly saved place inside it
are deduped naturally.

When places are provided, event and comment fetches switch from the
per-area optimized query to a global query + post-filter by the
combined element set; boost filtering already goes through in_filter
(renamed from in_area).

Motivation: the FE will introduce a /user/activity page combining
a signed-in user's saved places and saved areas into one feed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(v4): update stale in_area comment to in_filter

The helper was renamed when places were added to the element filter;
the boost comment still referenced the old name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(v4): reject unparseable places values with 400

Previously, ?places=foo silently dropped the invalid segment and fell
through to an unfiltered global response — surprising behavior when
the caller expects the filter to take effect. Switch filter_map(...ok())
to collect::<Result<_,_>>()? and return 400 Invalid Input on any
non-integer segment. Mirrors how ?areas= 404s on an unknown area.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(v4): cap days window on /v4/activity at 3650

The endpoint is unauthenticated and select_created_between scans all
events in the window. Without a ceiling on days, ?days=36500 forces a
100-year scan. Require 1 <= days <= 3650 (10y) and return 400 otherwise.

3650 leaves generous headroom for the area-feed UI's 30-day pagination
(≈120 load-mores of headroom) while closing the unbounded-range DoS
path; this also protects the pre-existing global fetch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(v4): cap places list length on /v4/activity at 500

An unbounded places list lets a caller build an arbitrarily large
HashSet<i64> from query input. 500 covers realistic power-user saved
lists (the planned /user/activity page on the FE); callers with more
can fall back to saving the containing area.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor(v4): parse places into HashSet to dedupe on input

Addresses Copilot review on PR #87:
- discussion_r3108284219: collect directly into HashSet<i64> rather
  than Vec then insert, removing the redundant conversion.
- discussion_r3108284246: MAX_PLACES now caps unique IDs, so a request
  like places=1,1,1,... is no longer rejected on dup-inflated length.

No behavior change for well-formed input; HashSet iteration order is
non-deterministic but subsequent code only unions into another HashSet
and final results are sorted by created_at.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(v4): cap places token count before parsing

Addresses CodeRabbit review on PR #87 (discussion_r3108325028): enforce
MAX_PLACES on the raw comma-separated token count before building the
HashSet, so a pathological input can't allocate a large intermediate
set before the guard rejects.

Trade-off noted: this reverts the "unique IDs" framing from the prior
commit. Legitimate clients (the planned /user/activity page joining
session.savedPlaces) don't send duplicates, so a raw-token cap is
correct in practice and closes the allocation window.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(v4): clarify places cap error message

Addresses CodeRabbit nit on PR #87 (discussion_r3108598972): the cap is
enforced on raw comma-separated tokens, but the error message said "IDs"
which implies a uniqueness-aware limit. Switch to "comma-separated
values" so the message matches what's actually counted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(v4): document /v4/activity endpoint (#88)

The activity feed endpoint was shipped without a corresponding doc
(same as #86's top-editors). Adds docs/rest/v4/activity.md covering
parameters (days / area / areas / places), response shape, examples,
and error cases, plus a link in the v4 README under "Implemented".

Includes the `?places=` parameter added in #87, so this branch should
merge after that one.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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