importeur 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +1 -2
- data/importeur.gemspec +1 -0
- data/lib/importeur/active_record_postgres_loader.rb +9 -3
- data/lib/importeur/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcad980a9f4b5d2f67784fec871dd170e5b48ce9180255d51c63b68629cdadae
|
4
|
+
data.tar.gz: 27ba1d50f9445283412b8b3bdfe1d1815209911d4bd09aaba543fc5fb70bbe79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f42cfe882b4c4278edec84a135007977275c9774ae7d24f68bc59b37e0a2d2c215ae6d88a7d74bec2b28bfeb742e71ec9a2a258800fc83352c1a1dbe9ca8c7
|
7
|
+
data.tar.gz: c8b77a7abcbe9e0be3745637c0d79ceaea048dbf3db04de7d43aa0c9aa808859453ff8c7ce4af8286e9e8a1127298e62560a0394675789e5881b25f9cfd1bbd9
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.3
|
data/README.md
CHANGED
@@ -64,8 +64,7 @@ It takes as arguments a data source that needs to implement
|
|
64
64
|
|
65
65
|
An `ActiveRecordPostgresLoader` exists, that has a few very specific
|
66
66
|
dependencies. As the name suggests, it imports data into a Postgres database
|
67
|
-
using `ActiveRecord`. Additionally,
|
68
|
-
`acts_as_paranoid`.
|
67
|
+
using `ActiveRecord`. Additionally, it supports `acts_as_paranoid` (optional).
|
69
68
|
|
70
69
|
Example use-cases can be found in the `spec/integration` directory.
|
71
70
|
|
data/importeur.gemspec
CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
33
|
spec.add_development_dependency 'activerecord', '<5'
|
34
|
+
spec.add_development_dependency 'acts_as_paranoid'
|
34
35
|
spec.add_development_dependency 'appnexusapi'
|
35
36
|
spec.add_development_dependency 'bucket_cake'
|
36
37
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
@@ -35,15 +35,16 @@ module Importeur
|
|
35
35
|
def store_record(attrs, records)
|
36
36
|
record = records.fetch(attrs[primary_key], model.new)
|
37
37
|
record.assign_attributes(attrs)
|
38
|
-
record.deleted_at = nil
|
38
|
+
record.deleted_at = nil if paranoid?
|
39
39
|
return unless record.changed?
|
40
40
|
record.imported_at = Time.now
|
41
41
|
record.save!
|
42
42
|
end
|
43
43
|
|
44
44
|
def records_for_batch(batch_ids)
|
45
|
-
model
|
46
|
-
|
45
|
+
relation = model
|
46
|
+
relation = relation.with_deleted if paranoid?
|
47
|
+
relation
|
47
48
|
.joins(batch_lookup_join_sql('INNER', batch_ids))
|
48
49
|
.index_by(&primary_key)
|
49
50
|
end
|
@@ -63,5 +64,10 @@ module Importeur
|
|
63
64
|
ON imported.primary_key = #{model.table_name}.#{primary_key}
|
64
65
|
SQL
|
65
66
|
end
|
67
|
+
|
68
|
+
def paranoid?
|
69
|
+
return @paranoid if defined?(@paranoid)
|
70
|
+
@paranoid = model.ancestors.map(&:to_s).include?('ActsAsParanoid::Core')
|
71
|
+
end
|
66
72
|
end
|
67
73
|
end
|
data/lib/importeur/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: importeur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Helge Rausch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: acts_as_paranoid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: appnexusapi
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -203,6 +217,7 @@ files:
|
|
203
217
|
- ".env"
|
204
218
|
- ".gitignore"
|
205
219
|
- ".rspec"
|
220
|
+
- ".ruby-version"
|
206
221
|
- ".travis.yml"
|
207
222
|
- CHANGELOG.md
|
208
223
|
- Gemfile
|