API: remove various associated fields included by default.
Remove various associated fields that were included by default on certain endpoints. API users can use the only param to include the full association if they need these fields. * /artists.json: urls. * /artist_urls.json: artist. * /comments.json: creator_name and updater_name. * /notes.json: creator_name. * /pools.json: creator_name. * /posts.json: uploader_name, children_ids, pixiv_ugoira_frame_data. * /post_appeals.json: is_resolved. * /post_versions.json: updater_name. * /uploads.json: uploader_name.
This commit is contained in:
@@ -4,10 +4,7 @@ class ArtistUrlsController < ApplicationController
|
||||
|
||||
def index
|
||||
@artist_urls = ArtistUrl.paginated_search(params).includes(model_includes(params))
|
||||
respond_with(@artist_urls) do |format|
|
||||
format.json { render json: @artist_urls.to_json(format_params) }
|
||||
format.xml { render xml: @artist_urls.to_xml(format_params) }
|
||||
end
|
||||
respond_with(@artist_urls)
|
||||
end
|
||||
|
||||
def update
|
||||
@@ -20,25 +17,12 @@ class ArtistUrlsController < ApplicationController
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[{artist: [:urls]}]
|
||||
[]
|
||||
else
|
||||
[:artist]
|
||||
end
|
||||
end
|
||||
|
||||
def format_params
|
||||
param_hash = {}
|
||||
if params[:only]
|
||||
param_hash[:only] = params[:only]
|
||||
else
|
||||
param_hash[:include] = [:artist]
|
||||
end
|
||||
if request.format.symbol == :xml
|
||||
param_hash[:root] = "artist-urls"
|
||||
end
|
||||
param_hash
|
||||
end
|
||||
|
||||
def artist_url_params
|
||||
permitted_params = %i[is_active]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user