Commit ef5f46c4 authored by Rafael Ravedutti's avatar Rafael Ravedutti

Include professional_id field on citizen uploads index

Signed-off-by: Rafael Ravedutti's avatarRafael Ravedutti <rrlmachado@inf.ufpr.br>
parent 09b632fd
Pipeline #16670 passed with stages
in 4 minutes and 2 seconds
......@@ -32,10 +32,21 @@ module Api::V1
# Sort uploads by date in descending order
@uploads = @uploads.order("created_at DESC")
# Uploads with professional id
uploads_with_professional = @uploads.as_json
# Add professional id to uploads
uploads_with_professional.each do |upload|
upload_citizen = Citizen.find(upload['citizen_id'])
professional = Professional.where(account_id: upload_citizen.account_id).first
upload[:professional_id] = professional.id
end
# Create response object
response = Hash.new
response[:num_entries] = @uploads.total_count
response[:entries] = @uploads.as_json
response[:entries] = uploads_with_professional
# Render uploads in JSON format
render json: response.to_json
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment