Files
fizzy/app/views/activities/_activity.json.jbuilder
T
Rob Zolkos 6a71856b3d Add JSON activities API endpoint (#2783)
* Add JSON events API endpoint

* Add regression test for event particulars defaults

* Move JSON events API to a dedicated ActivitiesController

The events endpoint served both the HTML day timeline and the JSON API
feed, but the two paths shared no data or behavior — the HTML side uses
DayTimelinesScoped while the JSON side built its own query. Splitting
into ActivitiesController gives the API its own home at
GET /:account/activities.json without dragging in the timeline
before_actions.

Also preloads comment creator in Event.preloaded to avoid an N+1 when
rendering comment eventables in the JSON feed.
2026-04-08 08:39:36 -04:00

22 lines
705 B
Ruby

json.(event, :id, :action)
json.created_at event.created_at.utc
json.description event.description_for(Current.user).to_plain_text
json.particulars event.api_particulars
json.url(
case event.eventable
when Comment then card_url(event.eventable.card, anchor: dom_id(event.eventable))
else polymorphic_url(event.eventable)
end
)
json.eventable_type event.eventable_type
json.eventable do
case event.eventable
when Card then json.partial! "cards/card", card: event.eventable
when Comment then json.partial! "cards/comments/comment", comment: event.eventable
end
end
json.board event.board, partial: "boards/board", as: :board
json.creator event.creator, partial: "users/user", as: :user