6a71856b3d
* 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.
29 lines
729 B
Ruby
29 lines
729 B
Ruby
module Event::Particulars
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
store_accessor :particulars, :assignee_ids
|
|
end
|
|
|
|
def assignees
|
|
@assignees ||= User.where id: assignee_ids
|
|
end
|
|
|
|
def api_particulars
|
|
nested = particulars.dig("particulars") || {}
|
|
|
|
case action.to_s
|
|
when "card_assigned", "card_unassigned"
|
|
{ "assignee_ids" => Array(assignee_ids) }
|
|
when "card_board_changed"
|
|
{ "old_board" => nested["old_board"].to_s, "new_board" => nested["new_board"].to_s }
|
|
when "card_title_changed"
|
|
{ "old_title" => nested["old_title"].to_s, "new_title" => nested["new_title"].to_s }
|
|
when "card_triaged"
|
|
{ "column" => nested["column"].to_s }
|
|
else
|
|
{}
|
|
end
|
|
end
|
|
end
|