Class: Quandl::Cassandra::Models::Column

Inherits:
Base
  • Object
show all
Defined in:
lib/quandl/cassandra/models/column.rb

Defined Under Namespace

Classes: Read, Write

Class Method Summary collapse

Class Method Details

.find_max_time_by_ids(ids, collapses, order) ⇒ Object



18
19
20
21
22
23
# File 'lib/quandl/cassandra/models/column.rb', line 18

def find_max_time_by_ids(ids, collapses, order)
  unique = collapses.uniq.count == 1
  time = find_max_time_by_ids_and_collapse(ids, collapses.first, order) if unique
  time = find_max_time_by_ids_and_collapses(ids, collapses, order) unless unique
  Date.jd(time) if time.is_a?(Integer)
end

.find_max_time_by_ids_and_collapse(ids, collapse, order) ⇒ Object



36
37
38
# File 'lib/quandl/cassandra/models/column.rb', line 36

def find_max_time_by_ids_and_collapse(ids, collapse, order)
  limit(1).order("type #{order}, time #{order}").where( id: ids, type: collapse ).select(:time, :type).to_a[0].try(:[], 'time')
end

.find_max_time_by_ids_and_collapses(ids, collapses, order) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/quandl/cassandra/models/column.rb', line 25

def find_max_time_by_ids_and_collapses(ids, collapses, order)
  # otherwise lookup each column seperately
  times = []
  ids.each_with_index do |id, index|
    column_collapse = collapses[index]
    next if column_collapse.blank?
    times << limit(1).order("type #{order}, time #{order}").where( id: id, type: column_collapse ).select(:time, :type).to_a[0].try(:[], 'time')
  end
  times.flatten.max
end

.read(*args) ⇒ Object



10
11
12
# File 'lib/quandl/cassandra/models/column.rb', line 10

def read(*args)
  Quandl::Cassandra::Models::Column::Read.perform(*args)[:data]
end

.write(*args) ⇒ Object



14
15
16
# File 'lib/quandl/cassandra/models/column.rb', line 14

def write(*args)
  Quandl::Cassandra::Models::Column::Write.perform(*args)
end