quandl_cassandra_models 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/UPGRADE.md +5 -0
- data/lib/quandl/cassandra/models/column/read/collapse.rb +1 -1
- data/lib/quandl/cassandra/models/column/read/offset.rb +0 -3
- data/lib/quandl/cassandra/models/column.rb +2 -2
- data/lib/quandl/cassandra/models/version.rb +1 -1
- data/spec/lib/quandl/cassandra/models/column/read_spec.rb +33 -17
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aed3773469f277df0b8e8eabd8a23dee5f7aeecd
|
4
|
+
data.tar.gz: 0e3a85bbe925f1c1ac37d1cde9f117067e6b3c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a9cf178b53e5c5dcf03f73eceb8b5eba7d3665a1e7f03b7e8fb0576c84986625a60ef348c303d6351f5a46357f01facaf962922633e2cd3d9d80e4862b7f71
|
7
|
+
data.tar.gz: 24227cf92fcdd8bbea8c67706f38291a018cb00fcf45621b8af18d32eec0c61361fba6d7f32d507cb3e961943aa337a65131c8853d1141c6898ad2aaced8bbc1
|
data/UPGRADE.md
CHANGED
@@ -9,7 +9,7 @@ class Quandl::Cassandra::Models::Column::Read::Collapse < Quandl::Cassandra::Mod
|
|
9
9
|
|
10
10
|
def select_column_frequencies
|
11
11
|
freqs = Quandl::Cassandra::Models::ColumnAttribute.where( id: column_ids ).select(:id, :frequency).to_a
|
12
|
-
column_ids.collect{|id| freqs.detect{|f| f['id'] == id }.try(:[], 'frequency') }
|
12
|
+
column_ids.collect{|id| freqs.detect{|f| f['id'] == id }.try(:[], 'frequency') }.collect(&:to_sym)
|
13
13
|
end
|
14
14
|
|
15
15
|
def build_column_collapses_using_frequencies(freqs, collapse)
|
@@ -51,9 +51,6 @@ class Quandl::Cassandra::Models::Column::Read::Offset < Quandl::Cassandra::Model
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def accuracy_with_limit
|
54
|
-
# # short circuit for now
|
55
|
-
# return 0
|
56
|
-
# revist this at a later date:
|
57
54
|
awl = accuracy
|
58
55
|
awl = awl + limit - 1 if limit && limit > 0
|
59
56
|
awl
|
@@ -17,8 +17,8 @@ class Quandl::Cassandra::Models::Column < Quandl::Cassandra::Base
|
|
17
17
|
|
18
18
|
def find_max_time_by_ids(ids, collapses, order)
|
19
19
|
unique = collapses.uniq.count == 1
|
20
|
-
time = find_max_time_by_ids_and_collapse(ids, collapses.first,
|
21
|
-
time = find_max_time_by_ids_and_collapses(ids, collapses,
|
20
|
+
time = find_max_time_by_ids_and_collapse(ids, collapses.first, order) if unique
|
21
|
+
time = find_max_time_by_ids_and_collapses(ids, collapses, order) unless unique
|
22
22
|
Date.jd(time) if time.is_a?(Integer)
|
23
23
|
end
|
24
24
|
|
@@ -1,27 +1,43 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
describe Quandl::Cassandra::Models::Column
|
4
|
+
describe Quandl::Cassandra::Models::Column do
|
5
5
|
|
6
6
|
let(:id){ rand(10000*10000) + 10000*10000 }
|
7
|
-
let(:data){ Quandl::Fabricate::Data.rand( columns: 1, rows: 15, nils: false, frequency: :annual ) }
|
8
|
-
before(:each){ Quandl::Cassandra::Models::Column.write( id: id, data: data ) }
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
8
|
+
describe ".read" do
|
9
|
+
context "data presence" do
|
10
|
+
|
11
|
+
let(:data){ Quandl::Fabricate::Data.rand( columns: 1, rows: 15, nils: false, frequency: :annual ) }
|
12
|
+
before(:each){ Quandl::Cassandra::Models::Column.write( id: id, data: data ) }
|
13
|
+
|
14
|
+
attrs = {}
|
15
|
+
{ transform: :rdiff, collapse: :annual, row: 0, column: 1 }.each do |key, value|
|
16
|
+
attrs[key] = value
|
17
|
+
it "should read #{attrs.to_query}" do
|
18
|
+
attrs[:id] = id
|
19
|
+
attrs[:column_ids] = Quandl::Cassandra::Dataset.find(id).column_ids
|
20
|
+
Quandl::Cassandra::Models::Column.read(attrs).should be_present
|
21
|
+
end
|
22
|
+
end
|
22
23
|
end
|
23
|
-
|
24
|
+
|
25
|
+
[:daily, :weekly, :monthly, :quarterly, :annual].each do |frequency|
|
26
|
+
context "data #{frequency}" do
|
27
|
+
|
28
|
+
let(:data){ Quandl::Fabricate::Data.rand( columns: 1, rows: 15, nils: false, frequency: frequency ) }
|
29
|
+
before(:each){ Quandl::Cassandra::Models::Column.write( id: id, data: data ) }
|
30
|
+
|
31
|
+
[-4, -1, 0, 3].each do |row_index|
|
32
|
+
it "should read row=#{row_index}" do
|
33
|
+
expected_date = data[row_index][0]
|
34
|
+
Quandl::Cassandra::Models::Column.read({ id: id, row: row_index })[0][0].should eq expected_date
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
24
41
|
end
|
25
|
-
|
26
42
|
|
27
43
|
end
|