deprecar timestamp en sensores

This commit is contained in:
f 2022-03-09 15:01:18 -03:00
parent bf0e764f65
commit e51ba79d88
3 changed files with 12 additions and 5 deletions

View file

@ -50,16 +50,16 @@ class ReadingsController < ActionController::API
:battery_status, :battery_status,
:sample, :sample,
:signature, :signature,
coordinates: %i[lat lng]) coordinates: %i[lat lng]).tap do |p|
p[:timestamp] = Time.at p[:timestamp]
rescue TypeError
end
end end
# Procesa los parámetros de un sensor # Procesa los parámetros de un sensor
def sensor_params(sensor) def sensor_params(sensor)
sensor.permit(:timestamp, :type, :value, :unit, :error).tap do |p| sensor.permit(:timestamp, :type, :value, :unit, :error).tap do |p|
p[:local_type] = p.delete :type p[:local_type] = p.delete :type
p[:timestamp] = Time.at p[:timestamp]
rescue TypeError
end end
end end
end end

View file

@ -3,5 +3,5 @@
class Sensor < ApplicationRecord class Sensor < ApplicationRecord
belongs_to :arduino belongs_to :arduino
validates_presence_of :timestamp, :local_type, :value, :unit validates_presence_of :local_type, :value, :unit
end end

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
class RemoveTimestampFromSensor < ActiveRecord::Migration[6.1]
def change
remove_column :sensors, :timestamp, :datetime
end
end