Add board settings fields to board JSON responses#2788
Add board settings fields to board JSON responses#2788flavorjones merged 4 commits intobasecamp:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds enriched board JSON responses by including public_description, public_description_html, and user_ids fields in the GET /boards/:id.json endpoint. The changes align with the existing board update API shape and add comprehensive test coverage along with updated documentation.
Changes:
- Added
public_descriptionandpublic_description_htmlfields to board show JSON responses - Added conditional
user_idsfield (only present whenall_access: false) - Added comprehensive controller tests covering the new fields and their conditional inclusion
- Updated API documentation with example response showing the new fields and conditional field behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test/controllers/boards_controller_test.rb |
Added three tests: one for public_description fields, one for user_ids when board is not all access, and one ensuring user_ids is excluded for all-access boards |
docs/API.md |
Updated board show endpoint documentation with new fields in example response and clarified conditional field behavior |
app/views/boards/show.json.jbuilder |
Added public_description, public_description_html, and conditional user_ids fields |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3df413f to
9a96410
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Re: trix-content class — Yes, Action Text's |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
flavorjones
left a comment
There was a problem hiding this comment.
Suggested a small style change, otherwise this looks good.
Prefer `unless` to `if !`
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| json.partial! "boards/board", board: @board | ||
| json.user_ids @board.users.ids unless @board.all_access? |
There was a problem hiding this comment.
user_ids is derived from board access records, but BoardsController#show uses conditional GET (fresh_when) with an ETag that doesn’t incorporate access changes. Because board access grants use Access.insert_all (bypassing the touch: true on Access#board), the board’s cache key/ETag can remain unchanged after membership updates, causing stale user_ids responses (304 Not Modified) for clients. Consider either touching the board when revising accesses, or including an access-based version (e.g., @board.accesses.maximum(:updated_at) / count) in the show ETag when rendering JSON with user_ids.
| @@ -1 +1,2 @@ | |||
| json.partial! "boards/board", board: @board | |||
| json.user_ids @board.users.ids unless @board.all_access? | |||
There was a problem hiding this comment.
@board.users.ids has no explicit ordering (the association is unordered), so the JSON array order can be nondeterministic across DBs/queries. For a stable API response (and to avoid clients seeing spurious diffs), consider returning a deterministic order (e.g., by ordering in SQL before plucking IDs).
| json.user_ids @board.users.ids unless @board.all_access? | |
| json.user_ids @board.users.order(:id).ids unless @board.all_access? |
| if board.published? | ||
| json.public_description board.public_description.to_plain_text | ||
| json.public_description_html board.public_description.to_s | ||
| json.public_url published_board_url(board) |
There was a problem hiding this comment.
This partial now calls board.published? and renders board.public_description (ActionText) for published boards. BoardsController#index only eager-loads creator: :identity, so on a cold fragment cache this will introduce per-board queries for publication and rich_text_public_description (N+1) when listing boards as JSON. Consider eager-loading these associations in the index query (e.g., include :publication and the rich text association) to keep index response query counts stable.
Summary
Add board settings read parity to the board JSON API.
What changed
public_descriptionandpublic_description_htmlto the board partial, gated onpublished?— available on both index and showuser_idsto board show JSON for boards with granular access (all_access: false)user_ids, and omission ofuser_idsfor all-access boardsdocs/api/sections/boards.mdto document the enriched board responseNotes
user_idsmatches the existing board update API shape and can be resolved viaGET /:account_slug/userspublic_descriptionfields follow the same pattern aspublic_url— only present when the board is publisheduser_idsis only present on show, and only whenall_accessisfalse