deprecar timestamp en sensores
This commit is contained in:
parent
bf0e764f65
commit
e51ba79d88
3 changed files with 12 additions and 5 deletions
|
@ -50,16 +50,16 @@ class ReadingsController < ActionController::API
|
|||
:battery_status,
|
||||
:sample,
|
||||
:signature,
|
||||
coordinates: %i[lat lng])
|
||||
coordinates: %i[lat lng]).tap do |p|
|
||||
p[:timestamp] = Time.at p[:timestamp]
|
||||
rescue TypeError
|
||||
end
|
||||
end
|
||||
|
||||
# Procesa los parámetros de un sensor
|
||||
def sensor_params(sensor)
|
||||
sensor.permit(:timestamp, :type, :value, :unit, :error).tap do |p|
|
||||
p[:local_type] = p.delete :type
|
||||
p[:timestamp] = Time.at p[:timestamp]
|
||||
rescue TypeError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
class Sensor < ApplicationRecord
|
||||
belongs_to :arduino
|
||||
|
||||
validates_presence_of :timestamp, :local_type, :value, :unit
|
||||
validates_presence_of :local_type, :value, :unit
|
||||
end
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveTimestampFromSensor < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
remove_column :sensors, :timestamp, :datetime
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue