app/controllers/iro/datapoints_controller.rb in iron_warbler-2.0.7.34 vs app/controllers/iro/datapoints_controller.rb in iron_warbler-2.0.7.35
- old
+ new
@@ -15,25 +15,11 @@
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
-
+ authorize! :datapoints_index, Iro
+ @symbol = params[:symbol] || params[:q]
+ @datapoints = Iro::Datapoint.where( symbol: @symbol ).order_by( quote_at: :desc ).limit(100)
end
end