Open
Conversation
|
@Sage-senpai is attempting to deploy a commit to the david's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Sage-senpai Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #390
Changes proposed
What were you told to do?
Implement a cursor-paginated user activity feed API with two endpoints:
GET /api/routes-f/activity— paginated feed of user activity eventsGET /api/routes-f/activity/daily— aggregated daily summaryWhat did you do?
Schema & migration
route_f_activity_eventstable with columns:id,user_id,type,actor_id,metadata(JSONB),created_at(user_id, created_at DESC)for efficient feed queriesapp/api/routes-f/activity/_lib/db.ts(lazy DDL) anddb/migrations/20260330_add_activity_events.sqlTypes (
types/activity.ts)ActivityEventType— union of 8 event types (tip_received, tip_sent, new_follower, stream_started, stream_ended, gift_received, gift_sent, recording_ready)ActivityTypeFilter— query param filter values (all, tips, follows, streams, gifts)FILTER_TO_TYPES— maps filter values to DB event typesActivityFeedResponse,DailySummaryResponseGET /api/routes-f/activity
limit(1-100, default 20),cursor(ISO timestamp),type(all|tips|follows|streams|gifts)created_at < $cursorwith fetchlimit + 1trick to detect next pageuserstable to include actor username/avatar{ events: [], next_cursor: null }(not 404)GET /api/routes-f/activity/daily?date=YYYY-MM-DD
dateparam (400 if missing/invalid)FILTER (WHERE ...)clausestips_received,tips_received_xlm,followers_gained,stream_duration_s,peak_viewersUpstream side-effect inserts
app/api/users/follow/route.ts— insertsnew_followerevent after successful followapp/api/streams/start/route.ts— insertsstream_startedon POST,stream_endedon DELETE (with duration/peak_viewers from session)app/api/routes-f/gifts/route.ts— inserts bothgift_receivedandgift_senteventsNote: Tip events (
tip_received/tip_sent) are not yet instrumented — there is no dedicated tip transaction route to hook into (onlytips/refresh-totalwhich is a read-only endpoint).Check List
Screenshots/Videos
N/A — API-only changes. Example responses:
GET /api/routes-f/activity?type=tips&limit=2
{ "events": [ { "id": "uuid", "type": "tip_received", "actor": { "username": "alice", "avatar": "/img/alice.png" }, "metadata": { "amount": "50", "currency": "XLM" }, "created_at": "2026-03-30T12:00:00.000Z" } ], "next_cursor": null }