rechazar los sensores vacíos

puede pasar que los arduinos no respondan
This commit is contained in:
f 2022-03-21 14:35:42 -03:00
parent 42cec427a8
commit 38bbeceab4

View file

@ -18,10 +18,12 @@ class ReadingsController < ActionController::API
reading.raw_transaction = request.raw_post reading.raw_transaction = request.raw_post
reading.verified = reading.verify_ssh_signature reading.verified = reading.verify_ssh_signature
params[:arduinos]&.each do |a| params[:arduinos]&.reject do |a|
a[:id].blank? || a[:sensores].empty?
end&.each do |a|
arduino = reading.arduinos.build local_id: a[:id], raspberry: raspberry arduino = reading.arduinos.build local_id: a[:id], raspberry: raspberry
a[:sensores]&.each do |s| a[:sensores].each do |s|
arduino.sensors.build(sensor_params s) arduino.sensors.build(sensor_params s)
end end
end end