app/controllers/iro/api/stocks_controller.rb in iron_warbler-2.0.7.26 vs app/controllers/iro/api/stocks_controller.rb in iron_warbler-2.0.7.27
- old
+ new
@@ -1,23 +1,24 @@
class Iro::Api::StocksController < Iro::ApiController
before_action :set_stock, only: [:show, :edit, :update, :destroy]
def index
+ @stocks = Iro::Stock.active
authorize! :index, Iro::Stock
respond_to do |format|
- format.json do
- render
- end
+ format.html
+ format.json
end
end
def show
authorize! :show, @stock
end_on = Time.now.to_date.in_time_zone('UTC')
+ begin_on = ( Time.now - 1.year ).to_date.in_time_zone('UTC')
begin_on = params[:begin_on].to_date.in_time_zone('UTC') if params[:begin_on]
end_on = params[:end_on].to_date.in_time_zone('UTC') if params[:end_on]
case params[:period]
when '1-mo'
@@ -27,15 +28,17 @@
begin_on = ( Time.now - 90.days ).to_date.in_time_zone('UTC')
# end_on = Time.now.to_date.in_time_zone('UTC')
when '1-yr'
begin_on = ( Time.now - 1.year ).to_date.in_time_zone('UTC')
# end_on = Time.now.to_date.in_time_zone('UTC')
+ when '5-yr'
+ begin_on = ( Time.now - 5.years ).to_date.in_time_zone('UTC')
end
@datapoints = Iro::Datapoint.where({
:quote_at.gte => begin_on,
:quote_at.lte => end_on,
- symbol: params[:ticker],
+ symbol: params[:ticker],
}).order_by({ quote_at: :asc })
end
def new
@stock = Iro::Stock.new