Sha256: 2f179495fde06da5fe8676e78d26e5f6198e471b3e315aa7bd04f0e1677b1e4b
Contents?: true
Size: 861 Bytes
Versions: 24
Compression:
Stored size: 861 Bytes
Contents
class Iro::DatapointsController < Iro::ApplicationController ## params: d, k, v def create authorize! :create, Iro::Datapoint begin Iro::Datapoint.create!( date: params[:d], kind: params[:k], value: params[:v], ) render json: { status: :ok } rescue Mongoid::Errors::Validations => e render json: { status: 401 }, status: 401 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
24 entries across 24 versions & 1 rubygems