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

Version Path
iron_warbler-2.0.7.34 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.33 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.32 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.31 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.30 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.29 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.28 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.27 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.26 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.25 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.24 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.23 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.22 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.21 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.20 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.19 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.18 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.17 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.16 app/controllers/iro/datapoints_controller.rb
iron_warbler-2.0.7.15 app/controllers/iro/datapoints_controller.rb