Class: Iro::Api::StocksController
- Inherits:
-
Iro::ApiController
- Object
- Iro::ApiController
- Iro::Api::StocksController
- Defined in:
- app/controllers/iro/api/stocks_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/iro/api/stocks_controller.rb', line 49 def create @stock = Iro::Stock.new(stock_params) :create, @stock if @stock.save flash_notice @stock else flash_alert @stock end redirect_to action: :index end |
#destroy ⇒ Object
72 73 74 75 |
# File 'app/controllers/iro/api/stocks_controller.rb', line 72 def destroy @stock.destroy redirect_to stocks_url, notice: 'Stock was successfully destroyed.' end |
#edit ⇒ Object
46 47 |
# File 'app/controllers/iro/api/stocks_controller.rb', line 46 def edit end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/iro/api/stocks_controller.rb', line 5 def index :index, Iro::Stock respond_to do |format| format.json do render end end end |
#new ⇒ Object
41 42 43 44 |
# File 'app/controllers/iro/api/stocks_controller.rb', line 41 def new @stock = Iro::Stock.new :new, @stock end |
#show ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/iro/api/stocks_controller.rb', line 15 def show :show, @stock end_on = Time.now.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' begin_on = ( Time.now - 30.days ).to_date.in_time_zone('UTC') # end_on = Time.now.to_date.in_time_zone('UTC') when '3-mo' 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') end @datapoints = Iro::Datapoint.where({ :quote_at.gte => begin_on, :quote_at.lte => end_on, symbol: params[:ticker], }).order_by({ quote_at: :asc }) end |