rechazar los sensores vacíos
puede pasar que los arduinos no respondan
This commit is contained in:
parent
42cec427a8
commit
38bbeceab4
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue