Sha256: 4a17f6bc81143feb56b343e0528d3cd37f4c38f4c2e6316e58626cbda9243ee8
Contents?: true
Size: 867 Bytes
Versions: 8
Compression:
Stored size: 867 Bytes
Contents
# require_dependency "iro/application_controller" class Iro::DatapointsController < Iro::ApplicationController ## params: d, k, v def create begin Iro::Datapoint.create( k: params[:k], v: params[:v], created_at: params[:time] ) render json: { status: :ok } rescue ActiveRecord::NotNullViolation => exception render json: { status: :unauthorized }, status: :unauthorized end end def index # from = '2023-12-20' # to = '2023-12-01' # points = Iro::Datapoint.where( k: params[:k] ).joins( :dates ) sql = "SELECT dps.k, dps.v, d.date FROM iro_datapoints as dps RIGHT JOIN dates d ON d.date = dps.d WHERE d.date BETWEEN '2023-12-01' AND '2023-12-31' ORDER BY d.date;" outs = ActiveRecord::Base.connection.execute(sql) puts! outs, 'outs' render json: outs end end
Version data entries
8 entries across 8 versions & 1 rubygems