Skip to content

feature(area): acitvity feed json#79

Merged
escapedcat merged 4 commits intomasterfrom
feature/area-feed-v2
Apr 9, 2026
Merged

feature(area): acitvity feed json#79
escapedcat merged 4 commits intomasterfrom
feature/area-feed-v2

Conversation

@escapedcat
Copy link
Copy Markdown
Collaborator

@escapedcat escapedcat commented Apr 8, 2026

Summary

  • Add optional area query param to GET /v4/activity (accepts area ID or alias)
  • When provided, filters events, comments, and boosts to places within that area
  • When omitted, existing global behavior is unchanged
  • Targeted error mapping: area not found returns 404, DB errors return 500

Why not the Atom feed?

The /feeds/ endpoints serve XML, split events and comments into separate feeds, and don't include boosts. The /v4/activity endpoint already merges all three into one JSON timeline — adding area scoping there was a one-param change vs
building a parallel feed system.

Tests

  • 10 tests total (6 existing + 4 new)
  • Area filtering tested for events, comments, and boosts separately
  • Area not found returns 404

PR description for btcmap.org-2nd:

Summary

  • New AreaFeed component replaces events-only list on area activity tab
  • Fetches from /v4/activity?area={alias} — shows edits, comments, and boosts in one timeline
  • Polymorphic cards: colored dots for edits, speech bubble for comments, lightning bolt for boosts
  • Load-more expands time window (30 days increments)
  • Race condition protection via generation counter
  • Error state with retry button
  • Vite dev proxy (/local-api -> localhost:8000) for local testing
  • Dead code cleanup: removed unused eventElements, ActivityEvent, formatElementID

Frontend MVP

image

MVP only. UI should be adjusted alter on if the API is clear

Summary by CodeRabbit

  • New Features

    • Added area-based activity filtering—retrieve events, comments, and boosts scoped to specific areas using the new optional area parameter.
    • Area aliases supported for streamlined filtering.
    • Returns 404 when the specified area does not exist.
  • Documentation

    • Updated development guidelines for SQL query standards.

@coderabbitai

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@escapedcat escapedcat marked this pull request as ready for review April 8, 2026 05:03
@escapedcat escapedcat requested a review from bubelov April 8, 2026 05:03
escapedcat and others added 4 commits April 9, 2026 10:45
Add optional `area` query parameter that accepts an area ID or alias.
When provided, the feed is filtered to only show activity for places
within that area. Existing behavior (global feed) is unchanged when
the parameter is omitted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only map QueryReturnedNoRows to 404 for area lookup; other errors
(pool exhaustion, DB corruption) correctly propagate as 500. Add tests
for comment and boost area filtering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace in-memory filtering with SQL subqueries that filter events and
comments by area_element membership at the DB level. This avoids loading
the full global dataset when an area is specified.

Boosts still use in-memory filtering because the invoice table stores
element_id in a description string, not a JOINable column. Extracted
an in_area() helper to deduplicate the membership check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move select_created_between_for_area queries from the activity handler
into the proper blocking_queries/queries layer for element_event and
element_comment. The handler now calls the DB layer like all other
endpoints.

Also update AGENTS.md to explicitly state that raw SQL must never be
embedded in REST/RPC handlers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@escapedcat escapedcat force-pushed the feature/area-feed-v2 branch from 5ad6bb0 to aa006e3 Compare April 9, 2026 02:47
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/rest/v4/activity.rs (1)

218-220: Minor inconsistency in time boundary for boosts.

The boost time check uses now as the upper bound with inclusive comparison (> now means <= now for inclusion), while events and comments use period_end (now + 1s) with exclusive SQL boundaries (< period_end). This creates a subtle difference where boosts exclude items created exactly at now, but events/comments include items up to 1 second in the future.

For consistency, consider using period_end:

♻️ Optional: Align time boundaries with events/comments
-        if created_at < day_ago || created_at > now {
+        if created_at < day_ago || created_at > period_end {
             continue;
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rest/v4/activity.rs` around lines 218 - 220, The boost time filter in
activity.rs currently uses `if created_at < day_ago || created_at > now {
continue; }` which excludes items at exactly `now`; change it to use the same
`period_end` upper bound used by events/comments and the same exclusive
semantics: replace the check with `if created_at < day_ago || created_at >=
period_end { continue; }`, referencing the `created_at`, `day_ago`, and
`period_end` variables in the boosts processing logic so boosts align with
events/comments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/rest/v4/activity.rs`:
- Around line 218-220: The boost time filter in activity.rs currently uses `if
created_at < day_ago || created_at > now { continue; }` which excludes items at
exactly `now`; change it to use the same `period_end` upper bound used by
events/comments and the same exclusive semantics: replace the check with `if
created_at < day_ago || created_at >= period_end { continue; }`, referencing the
`created_at`, `day_ago`, and `period_end` variables in the boosts processing
logic so boosts align with events/comments.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bd465755-16f0-417d-8f02-0fe032765796

📥 Commits

Reviewing files that changed from the base of the PR and between 5ad6bb0 and aa006e3.

📒 Files selected for processing (6)
  • AGENTS.md
  • src/db/main/element_comment/blocking_queries.rs
  • src/db/main/element_comment/queries.rs
  • src/db/main/element_event/blocking_queries.rs
  • src/db/main/element_event/queries.rs
  • src/rest/v4/activity.rs
✅ Files skipped from review due to trivial changes (1)
  • AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/db/main/element_event/queries.rs
  • src/db/main/element_comment/queries.rs
  • src/db/main/element_event/blocking_queries.rs
  • src/db/main/element_comment/blocking_queries.rs

@escapedcat escapedcat merged commit a6a582c into master Apr 9, 2026
2 checks passed
@escapedcat escapedcat deleted the feature/area-feed-v2 branch April 9, 2026 03:02
@escapedcat escapedcat restored the feature/area-feed-v2 branch April 9, 2026 05:58
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