cartomodel 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/Rakefile +2 -0
- data/lib/cartomodel/models/synchronizable.rb +1 -0
- data/lib/cartomodel/synchronizer.rb +32 -0
- data/lib/cartomodel/version.rb +1 -1
- data/lib/cartomodel.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: def3abed8f01159d97c5a7b1db53e41928c59a36
|
4
|
+
data.tar.gz: 128b0d8c6ed6bd34c91322d44a428855b1d8f090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab911b7e60230402d01e33000b2d365d92bf882be676e982bfa5f6aa616abe5414ef32e82d642a82db3180b9ea96ec9191456a507b98462fc63e3d1211815a29
|
7
|
+
data.tar.gz: 8cc73daab626fe6b3bc2fe500efc2357915c0dfd1c352165709d672ace31bba262e1b4ae7a639e44abeab493068fcb9235c5d19903f2568c21978d22121f9fb4
|
data/README.md
CHANGED
@@ -36,4 +36,14 @@ class AddCartomodelColumnsYourModel < ActiveRecord::Migration
|
|
36
36
|
add_column :indicator_configs, :sync_state, :integer
|
37
37
|
end
|
38
38
|
end
|
39
|
-
```
|
39
|
+
```
|
40
|
+
|
41
|
+
# Sync
|
42
|
+
|
43
|
+
If CartoDB, for some reason, fails to save your data, you can retry later using a rake task:
|
44
|
+
|
45
|
+
```
|
46
|
+
rake cartomodel:sync
|
47
|
+
```
|
48
|
+
|
49
|
+
Currently the task prints no output on progress or success
|
data/Rakefile
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Cartomodel
|
2
|
+
class Synchronizer
|
3
|
+
def self.sync_all
|
4
|
+
self.get_failed_synced_instances.each do |object|
|
5
|
+
object.class.skip_callback(:create, :before, :create_on_cartodb)
|
6
|
+
object.class.skip_callback(:update, :before, :update_on_cartodb)
|
7
|
+
|
8
|
+
begin
|
9
|
+
if object.cartodb_id then
|
10
|
+
object.update_on_cartodb
|
11
|
+
else
|
12
|
+
object.create_on_cartodb
|
13
|
+
end
|
14
|
+
object.save
|
15
|
+
ensure
|
16
|
+
object.class.set_callback(:create, :before, :create_on_cartodb)
|
17
|
+
object.class.set_callback(:update, :before, :update_on_cartodb)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_failed_synced_instances
|
23
|
+
result = []
|
24
|
+
ActiveRecord::Base.descendants.each do |active_record_descendant|
|
25
|
+
next if active_record_descendant.included_modules.exclude? Cartomodel::Model::Synchronizable or !ActiveRecord::Base.connection.column_exists? active_record_descendant.table_name, :sync_state
|
26
|
+
result.concat active_record_descendant.where(sync_state: Cartomodel::Model::Synchronizable::STATE_FAILED)
|
27
|
+
end
|
28
|
+
result
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/lib/cartomodel/version.rb
CHANGED
data/lib/cartomodel.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartomodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/cartomodel/errors.rb
|
136
136
|
- lib/cartomodel/models/synchronizable.rb
|
137
137
|
- lib/cartomodel/query_generator.rb
|
138
|
+
- lib/cartomodel/synchronizer.rb
|
138
139
|
- lib/cartomodel/version.rb
|
139
140
|
homepage: http://vizzuality.com
|
140
141
|
licenses:
|