quandl_cassandra_models 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0b9bce66075016dfa7a439bf9d274b0f58a4e38
|
4
|
+
data.tar.gz: ac064b563b6e8c59d13a51de267f01fdeed36c4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 634aaae22f9bc56383f8a621fe82504ce04bbb34ba4a235972b882dbecfdcc0014b3afcddb5e04693edc6f2f8e6cf646cd09538c45d1097a51760c67257ded1b
|
7
|
+
data.tar.gz: a662350a92bfc60d97081a1a861f9ece91ae5316655c21db4c4a0f00f049352fa65249c5ff6d1190af3554b15a58818a4b8179dfbfa0b22861ac0183c139fffa
|
data/examples/pry.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
2
|
+
|
3
|
+
QUANDL_LOGGER = true
|
4
|
+
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
require "quandl/cassandra"
|
8
|
+
require "quandl/cassandra/models"
|
9
|
+
require "quandl/fabricate"
|
10
|
+
|
11
|
+
include Quandl::Cassandra::Models
|
12
|
+
|
13
|
+
logger = Logger.new( 'log/example.log', 2, 52428800 )
|
14
|
+
logger.formatter = proc do |severity, datetime, progname, msg|
|
15
|
+
"[#{datetime.strftime("%Y-%m-%d %H:%M:%S")}]: #{msg}\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
class Quandl::Logger::Puts
|
19
|
+
def self.debug(*args)
|
20
|
+
puts(*args)
|
21
|
+
end
|
22
|
+
def self.info(*args)
|
23
|
+
puts(*args)
|
24
|
+
end
|
25
|
+
def self.error(*args)
|
26
|
+
puts(*args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Quandl::Logger.use(Quandl::Logger::Puts)
|
31
|
+
|
32
|
+
Quandl::Cassandra.configure do |c|
|
33
|
+
c.hosts = ['192.168.33.10']
|
34
|
+
c.keyspace = 'wikiposit_test'
|
35
|
+
c.consistency = :one
|
36
|
+
end
|
37
|
+
|
38
|
+
d = Dataset.create(id: rand(1000), data: Quandl::Fabricate::Data.rand )
|
39
|
+
d.columns.collect(&:delete)
|
40
|
+
d = Dataset.find(d.id)
|
41
|
+
|
42
|
+
binding.pry
|
@@ -8,8 +8,9 @@ class Quandl::Cassandra::Models::Column::Read::Collapse < Quandl::Cassandra::Mod
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def select_column_frequencies
|
11
|
-
freqs = Quandl::Cassandra::Models::ColumnAttribute.where( id: column_ids ).select(:id, :frequency).to_a
|
12
|
-
|
11
|
+
freqs = Quandl::Cassandra::Models::ColumnAttribute.where( id: column_ids ).select(:id, :frequency).to_a unless column_ids.blank?
|
12
|
+
freqs = [] if freqs.blank?
|
13
|
+
column_ids.collect{|id| freqs.detect{|f| f['id'] == id }.try(:[], 'frequency').try(&:to_sym) }
|
13
14
|
end
|
14
15
|
|
15
16
|
def build_column_collapses_using_frequencies(freqs, collapse)
|
@@ -30,6 +30,7 @@ class Quandl::Cassandra::Models::Dataset < Quandl::Cassandra::Base
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def data
|
33
|
+
repair_columns
|
33
34
|
# data set?
|
34
35
|
return read_attribute(:data) if data?
|
35
36
|
# read data
|
@@ -84,4 +85,12 @@ class Quandl::Cassandra::Models::Dataset < Quandl::Cassandra::Base
|
|
84
85
|
Quandl::Logger.error("#{self.class.name}.id #{id} #{e}")
|
85
86
|
end
|
86
87
|
|
88
|
+
def repair_columns
|
89
|
+
return if self.new_record?
|
90
|
+
columns.each do |c|
|
91
|
+
c.frequency = frequency if c.frequency.blank?
|
92
|
+
c.save if c.changed? || c.new_record?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
87
96
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_cassandra_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Hilscher
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- Rakefile
|
109
109
|
- UPGRADE.md
|
110
110
|
- config/cassandra.yml
|
111
|
+
- examples/pry.rb
|
111
112
|
- lib/quandl/cassandra/models.rb
|
112
113
|
- lib/quandl/cassandra/models/column.rb
|
113
114
|
- lib/quandl/cassandra/models/column/read.rb
|