Class: Quandl::Cassandra::Models::Column
- Inherits:
-
Base
- Object
- Base
- Quandl::Cassandra::Models::Column
- Defined in:
- lib/quandl/cassandra/models/column.rb
Defined Under Namespace
Class Method Summary collapse
- .find_max_time_by_ids(ids, collapses, order) ⇒ Object
- .find_max_time_by_ids_and_collapse(ids, collapse, order) ⇒ Object
- .find_max_time_by_ids_and_collapses(ids, collapses, order) ⇒ Object
- .read(*args) ⇒ Object
- .write(*args) ⇒ Object
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 |