Files
fizzy/app/controllers/activities_controller.rb
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

31 lines
640 B
Ruby

class ActivitiesController < ApplicationController
ACTIONS = %w[
card_assigned
card_auto_postponed
card_board_changed
card_closed
card_postponed
card_published
card_reopened
card_sent_back_to_triage
card_title_changed
card_triaged
card_unassigned
comment_created
].freeze
def index
set_page_and_extract_portion_from(activities)
end
private
def activities
Current.user.accessible_events
.preloaded
.where(action: ACTIONS)
.for_creators(params[:creator_ids])
.for_boards(params[:board_ids])
.reverse_chronologically
end
end