Class: Backend::Cells::QuandlCellsController

Inherits:
BaseController show all
Defined in:
app/controllers/backend/cells/quandl_cells_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#current_theme

Instance Method Summary collapse

Methods inherited from BaseController

account_lettering_states_crit, accounts_range_crit, amount_range_crit, crit_params, journal_entries_states_crit, journal_letter_crit, journal_period_crit, journals_crit, search_conditions

Methods inherited from ApplicationController

#after_sign_in_path_for, #authorized?, human_action_name, #human_action_name, #session_controller?

Instance Method Details

#showObject


7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/backend/cells/quandl_cells_controller.rb', line 7

def show
  start = Time.zone.today << 12
  finish = start >> 12 - 1
  api_key = ENV['QUANDL_API_KEY']
  Quandl::ApiConfig.api_key = api_key
  # Quandl::ApiConfig.api_version = '2015-04-09'
  dataset = params[:dataset] || 'CHRIS/LIFFE_EBM4'
  identifier = Identifier.find_by(nature: :quandl_token)
  token = (identifier ? identifier.value : api_key)
  @data = Quandl::Dataset.get(dataset).data(params: { start_date: started, end_date: finished, order: 'asc' })
  @data if @data.any?
end