sample_data_dump 0.0.1 → 0.0.2

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: 9cc7e8b7228910401bba4a6183eae46a28c4a3b2
4
- data.tar.gz: 2170275aa22f92f616dc221695fdd291bad88ef8
3
+ metadata.gz: 42b460018084e41b910908bbafb017a58f4cd918
4
+ data.tar.gz: e09b53a900e7859880eb521d30b459e33d7b33c3
5
5
  SHA512:
6
- metadata.gz: be2af199d1d6d3ff13e4b9c49a181cc96aa8fcc573fcc12a64e2d199e5b69548acd1fa8a98d35b29448e9cb1dfabb0687af5b8f86127bb83c60a14ee7e516566
7
- data.tar.gz: 43044756c988a517ec8b76474ed4963b70d33e4e13b8d731d7e2ef02f0cb392b45c1c5ffe9321350f301c7f8407bd2514499d2b08e9fe54b40c70e196d212a4a
6
+ metadata.gz: 04f4391e631cb33f8fe5e9c7d443d8ad65ab2d9e89a274477cb8bcb9af178de192e970872a6f1f7c03337453894fde2e56b0b82811c588ad7295060f5afb4f50
7
+ data.tar.gz: 2ec63119a0593f6285da5569762a4011cd3742d8add99f0b0070d64131d60caddd752fcb28ddc85f083326fe69f314cd55a4cc7d07e73d0b180a4e03f4de0265
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
+ compacted_dump/
1
2
  coverage/
3
+ .rspec_status
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.0.2
2
+
3
+ * Split all I/O across multiple gateways based on data type
4
+ * Changed use cases to commands; use cases imply an actor
5
+
1
6
  0.0.1
2
7
 
3
8
  * First release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sample_data_dump (0.0.1)
4
+ sample_data_dump (0.0.2)
5
5
  dry-matcher
6
6
  dry-monads
7
7
  dry-struct
data/README.md CHANGED
@@ -6,12 +6,70 @@ This gem provides:
6
6
 
7
7
  ## Usage
8
8
 
9
- 1. Create a class that implements the persistence interface.
10
- 2. Pass it to the appropriate use case.
11
- 3. Use the result to take your next action.
9
+ 1. Create a class that implements the CompressedDumpStorageGateway interface.
10
+ 2. Create a class that implements the DataStoreGateway interface.
11
+ 3. Initialize your gateway classes and a Settings class.
12
+ 4. Pass the gateways and settings to the appropriate command.
13
+ 5. Use the result to take your next action.
12
14
 
13
15
  ```
14
- SampleDataDump::UseCases::ActorDownloadsSampleDataFiles.new(persistence).result
16
+ settings = SampleDataDump::Settings.new(
17
+ compacted_dump_directory: '/tmp/compacted_dumps',
18
+ config_file_path: 'config/sample_data_dump.yml'
19
+ )
20
+ local_file_system = SampleDataDump::Gateways::LocalFileSystem.new(settings)
21
+ s3_storage = AmazonS3CompressedDumpStorageGateway.new(my_amazon_settings)
22
+ postgres_db = PostgresDataStoreGateway.new(my_postgres_settings)
23
+
24
+ SampleDataDump::Commands::DownloadCompressedDataDumps.new(local_file_system, s3_storage, settings).result.bind do
25
+ SampleDataDump::Commands::DecompressAndLoadSampleDataDumps.new(local_file_system, postgres_db, settings).result
26
+ end
27
+ ```
28
+
29
+ Some useful source code for creating rake tasks:
30
+
31
+ ```
32
+ namespace :sample_data do
33
+ desc 'dumps sample data to files'
34
+ task dump: :environment do
35
+ settings = SampleDataDump::Entities::Settings.new
36
+ local_file_system = SampleDataDump::Gateways::LocalFileSystem.new(settings)
37
+ data_store = MySampleDataDumpDataStore::Gateway.new(ActiveRecord::Base.connection, settings)
38
+ command = SampleDataDump::Commands::DumpSampleDataToFilesAndCompress.new(local_file_system, data_store)
39
+ result = command.result
40
+ puts result.failure if result.failure?
41
+ end
42
+
43
+ desc 'uploads compressed sample data files to storage'
44
+ task upload: :environment do
45
+ settings = SampleDataDump::Entities::Settings.new
46
+ local_file_system = SampleDataDump::Gateways::LocalFileSystem.new(settings)
47
+ compressed_dump_storage = MySampleDataRemoteStorage::Gateway.new(ActiveRecord::Base.connection, settings)
48
+ command = SampleDataDump::Commands::UploadCompressedSampleDataDumps.new(local_file_system, compressed_dump_storage)
49
+ result = command.result
50
+ puts result.failure if result.failure?
51
+ end
52
+
53
+ desc 'downloads sample data files from storage'
54
+ task download: :environment do
55
+ settings = SampleDataDump::Entities::Settings.new
56
+ local_file_system = SampleDataDump::Gateways::LocalFileSystem.new(settings)
57
+ compressed_dump_storage = MySampleDataRemoteStorage::Gateway.new(ActiveRecord::Base.connection, settings)
58
+ command = SampleDataDump::Commands::DownloadCompressedDataDumps.new(local_file_system, compressed_dump_storage)
59
+ result = command.result
60
+ puts result.failure if result.failure?
61
+ end
62
+
63
+ desc 'populates data store from downloaded sample data files'
64
+ task load: :environment do
65
+ settings = SampleDataDump::Entities::Settings.new
66
+ local_file_system = SampleDataDump::Gateways::LocalFileSystem.new(settings)
67
+ data_store = MySampleDataDumpDataStore::Gateway.new(ActiveRecord::Base.connection, settings)
68
+ command = SampleDataDump::Commands::DecompressAndLoadSampleDataDumps.new(local_file_system, data_store)
69
+ result = command.result
70
+ puts result.failure if result.failure?
71
+ end
72
+ end
15
73
  ```
16
74
 
17
75
  ## Installation
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SampleDataDump
4
+ module Commands
5
+ class DecompressAndLoadSampleDataDumps
6
+ def initialize(local_file_system_gateway, data_store_gateway)
7
+ @local_file_system_gateway = local_file_system_gateway
8
+ @data_store_gateway = data_store_gateway
9
+ end
10
+
11
+ def result
12
+ @local_file_system_gateway.load_table_configurations.fmap do |table_configs|
13
+ result = process_table_configs_list(table_configs)
14
+ return result if result.failure?
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def process_table_configs_list(table_configs)
21
+ table_configs.reverse_each do |table_config|
22
+ @data_store_gateway.wipe_table(table_config)
23
+ end
24
+
25
+ results = table_configs.map do |table_config|
26
+ result = process_table_config(table_config)
27
+ return result if result.failure?
28
+ end
29
+ results.last || Dry::Monads::Success(true)
30
+ end
31
+
32
+ def process_table_config(table_config)
33
+ @data_store_gateway.valid?(table_config).bind do
34
+ @local_file_system_gateway.decompress_compressed_dump_file(table_config).bind do
35
+ @data_store_gateway.load_dump_file(table_config).bind do
36
+ @data_store_gateway.reset_sequence(table_config)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SampleDataDump
4
+ module Commands
5
+ class DownloadCompressedSampleDataDumps
6
+ def initialize(local_file_system_gateway, compressed_dump_storage_gateway)
7
+ @local_file_system_gateway = local_file_system_gateway
8
+ @compressed_dump_storage_gateway = compressed_dump_storage_gateway
9
+ end
10
+
11
+ def result
12
+ @local_file_system_gateway.clean_dump_directory.bind do
13
+ @local_file_system_gateway.load_table_configurations.fmap do |table_configs|
14
+ result = process_table_configs_list(table_configs)
15
+ return result if result.failure?
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def process_table_configs_list(table_configs)
23
+ results = table_configs.map do |table_config|
24
+ result = @compressed_dump_storage_gateway.retrieve_compressed_dump_file(table_config)
25
+ return result if result.failure?
26
+ end
27
+ results.last || Dry::Monads::Success(true)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SampleDataDump
4
+ module Commands
5
+ class DumpSampleDataToFilesAndCompress
6
+ def initialize(local_file_system_gateway, data_store_gateway)
7
+ @local_file_system_gateway = local_file_system_gateway
8
+ @data_store_gateway = data_store_gateway
9
+ end
10
+
11
+ def result
12
+ @local_file_system_gateway.clean_dump_directory.bind do
13
+ @local_file_system_gateway.load_table_configurations.fmap do |table_configs|
14
+ result = process_table_configs_list(table_configs)
15
+ return result if result.failure?
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def process_table_configs_list(table_configs)
23
+ results = table_configs.map do |table_config|
24
+ result = process_table_config(table_config)
25
+ return result if result.failure?
26
+ end
27
+ results.last || Dry::Monads::Success(true)
28
+ end
29
+
30
+ def process_table_config(table_config)
31
+ @data_store_gateway.valid?(table_config).bind do
32
+ @data_store_gateway.dump_to_local_file(table_config).bind do
33
+ @local_file_system_gateway.compress_dump_file(table_config)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SampleDataDump
4
+ module Commands
5
+ class UploadCompressedSampleDataDumps
6
+ def initialize(local_file_system_gateway, compressed_dump_storage_gateway)
7
+ @local_file_system_gateway = local_file_system_gateway
8
+ @compressed_dump_storage_gateway = compressed_dump_storage_gateway
9
+ end
10
+
11
+ def result
12
+ @local_file_system_gateway.load_table_configurations.fmap do |table_configs|
13
+ result = process_table_configs_list(table_configs)
14
+ return result if result.failure?
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def process_table_configs_list(table_configs)
21
+ results = table_configs.map do |config|
22
+ result = @compressed_dump_storage_gateway.store_compressed_dump_file(config)
23
+ return result if result.failure?
24
+ end
25
+ results.last || Dry::Monads::Success(true)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/struct'
4
+ require 'sample_data_dump/types'
5
+
6
+ module SampleDataDump
7
+ module Entities
8
+ class Settings < Dry::Struct
9
+ attribute :compacted_dump_directory, Types::Strict::String.default('compacted_dump')
10
+ attribute :config_file_path, Types::Strict::String.default('config/sample_data_dump.yml')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry/monads/all'
4
+ require 'sample_data_dump/entities/table_configuration'
5
+ require 'sample_data_dump/helpers/dump_file'
6
+ require 'sample_data_dump/interfaces/local_file_system_gateway'
7
+ require 'yaml'
8
+
9
+ module SampleDataDump
10
+ module Gateways
11
+ class LocalFileSystem
12
+ extend Forwardable
13
+ implements_interface Interfaces::LocalFileSystemGateway
14
+
15
+ def initialize(settings)
16
+ @settings = settings
17
+ @sample_data_dump_config = YAML.load_file(config_file_path)
18
+
19
+ `mkdir -p #{compacted_dump_directory}`
20
+ end
21
+
22
+ def clean_dump_directory
23
+ `rm -rf #{compacted_dump_directory}/*.sql`
24
+ `rm -rf #{compacted_dump_directory}/*.sql.tar.gz`
25
+ Dry::Monads::Success(true)
26
+ end
27
+
28
+ def compress_dump_file(table_configuration)
29
+ dump_file_helper = Helpers::DumpFile.new(table_configuration, @settings)
30
+ uncompressed_file_path = dump_file_helper.local_dump_file_path
31
+ uncompressed_file_name = dump_file_helper.local_dump_file_name
32
+ compressed_file_name = dump_file_helper.local_compressed_dump_file_name
33
+ compressed_file_path = dump_file_helper.local_compressed_dump_file_path
34
+
35
+ unless File.exists?(uncompressed_file_path)
36
+ return Dry::Monads::Failure("No file found at #{uncompressed_file_path}")
37
+ end
38
+
39
+ `cd #{compacted_dump_directory}; tar -zcf #{compressed_file_name} #{uncompressed_file_name}`
40
+
41
+ if File.exist?(compressed_file_path)
42
+ Dry::Monads::Success(compressed_file_path)
43
+ else
44
+ Dry::Monads::Failure("No file found at #{compressed_file_path} after compressing")
45
+ end
46
+ end
47
+
48
+ def decompress_compressed_dump_file(table_configuration)
49
+ dump_file_helper = Helpers::DumpFile.new(table_configuration, @settings)
50
+ compressed_file_name = dump_file_helper.local_compressed_dump_file_name
51
+ compressed_file_path = dump_file_helper.local_compressed_dump_file_path
52
+ unless File.exist?(compressed_file_path)
53
+ return Dry::Monads::Failure("#{compressed_file_path} does not exist for decompressing!")
54
+ end
55
+
56
+ `cd #{compacted_dump_directory}; tar -zxf #{compressed_file_name}`
57
+ Dry::Monads::Success(true)
58
+ end
59
+
60
+ def load_table_configurations
61
+ result = []
62
+ @sample_data_dump_config.each_pair do |schema_name, schema_config_hash|
63
+ schema_config_hash.each_pair do |table_name, table_config_hash|
64
+ dump_where = table_config_hash&.[]('dump_where') || '1 = 1'
65
+ obfuscate_columns = table_config_hash&.[]('obfuscate_columns') || []
66
+ result << Entities::TableConfiguration.new(
67
+ schema_name: schema_name,
68
+ table_name: table_name,
69
+ dump_where: dump_where,
70
+ obfuscate_columns: obfuscate_columns
71
+ )
72
+ end
73
+ end
74
+ Dry::Monads::Success(result)
75
+ end
76
+
77
+ private
78
+
79
+ attr_reader :settings
80
+ def_delegators :settings, :compacted_dump_directory, :config_file_path
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SampleDataDump
4
+ module Helpers
5
+ class DumpFile
6
+ extend Forwardable
7
+
8
+ def initialize(table_configuration, settings)
9
+ @table_configuration = table_configuration
10
+ @settings = settings
11
+ end
12
+
13
+ def local_compressed_dump_file_name
14
+ "#{@table_configuration.schema_name}.#{@table_configuration.table_name}.sql.tar.gz"
15
+ end
16
+
17
+ def local_compressed_dump_file_path
18
+ "#{compacted_dump_directory}/#{local_compressed_dump_file_name}"
19
+ end
20
+
21
+ def local_dump_file_name
22
+ "#{@table_configuration.schema_name}.#{@table_configuration.table_name}.sql"
23
+ end
24
+
25
+ def local_dump_file_path
26
+ "#{compacted_dump_directory}/#{local_dump_file_name}"
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :settings
32
+ def_delegators :settings, :compacted_dump_directory
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'duckface'
4
+
5
+ module SampleDataDump
6
+ module Interfaces
7
+ module CompressedDumpStorageGateway
8
+ extend Duckface::ActsAsInterface
9
+
10
+ def retrieve_compressed_dump_file(_table_configuration)
11
+ raise NotImplementedError
12
+ end
13
+
14
+ def store_compressed_dump_file(_table_configuration)
15
+ raise NotImplementedError
16
+ end
17
+ end
18
+ end
19
+ end
@@ -4,14 +4,10 @@ require 'duckface'
4
4
 
5
5
  module SampleDataDump
6
6
  module Interfaces
7
- module Persistence
7
+ module DataStoreGateway
8
8
  extend Duckface::ActsAsInterface
9
9
 
10
- def decompress_compressed_dump_file(_table_configuration)
11
- raise NotImplementedError
12
- end
13
-
14
- def dump_and_compress_data_to_local_file(_table_configuration)
10
+ def dump_to_local_file(_table_configuration)
15
11
  raise NotImplementedError
16
12
  end
17
13
 
@@ -19,22 +15,10 @@ module SampleDataDump
19
15
  raise NotImplementedError
20
16
  end
21
17
 
22
- def load_table_configurations
23
- raise NotImplementedError
24
- end
25
-
26
- def move_compressed_dump_file_to_central_location(_table_configuration)
27
- raise NotImplementedError
28
- end
29
-
30
18
  def reset_sequence(_table_configuration)
31
19
  raise NotImplementedError
32
20
  end
33
21
 
34
- def retrieve_compressed_dump_file_from_central_location(_table_configuration)
35
- raise NotImplementedError
36
- end
37
-
38
22
  def valid?(_table_configuration)
39
23
  raise NotImplementedError
40
24
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'duckface'
4
+
5
+ module SampleDataDump
6
+ module Interfaces
7
+ module LocalFileSystemGateway
8
+ extend Duckface::ActsAsInterface
9
+
10
+ def clean_dump_directory
11
+ raise NotImplementedError
12
+ end
13
+
14
+ def compress_dump_file(_table_configuration)
15
+ raise NotImplementedError
16
+ end
17
+
18
+ def decompress_compressed_dump_file(_table_configuration)
19
+ raise NotImplementedError
20
+ end
21
+
22
+ def load_table_configurations
23
+ raise NotImplementedError
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SampleDataDump
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sample_data_dump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bellroy Dev Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2018-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-matcher
@@ -132,7 +132,6 @@ files:
132
132
  - ".gitignore"
133
133
  - ".reek.yml"
134
134
  - ".rspec"
135
- - ".rspec_status"
136
135
  - ".rubocop.yml"
137
136
  - ".ruby-version"
138
137
  - CHANGELOG.md
@@ -141,13 +140,18 @@ files:
141
140
  - Guardfile
142
141
  - README.md
143
142
  - lib/sample_data_dump.rb
143
+ - lib/sample_data_dump/commands/decompress_and_load_sample_data_dumps.rb
144
+ - lib/sample_data_dump/commands/download_compressed_sample_data_dumps.rb
145
+ - lib/sample_data_dump/commands/dump_sample_data_to_files_and_compress.rb
146
+ - lib/sample_data_dump/commands/upload_compressed_sample_data_dumps.rb
147
+ - lib/sample_data_dump/entities/settings.rb
144
148
  - lib/sample_data_dump/entities/table_configuration.rb
145
- - lib/sample_data_dump/interfaces/persistence.rb
149
+ - lib/sample_data_dump/gateways/local_file_system.rb
150
+ - lib/sample_data_dump/helpers/dump_file.rb
151
+ - lib/sample_data_dump/interfaces/compressed_dump_storage_gateway.rb
152
+ - lib/sample_data_dump/interfaces/data_store_gateway.rb
153
+ - lib/sample_data_dump/interfaces/local_file_system_gateway.rb
146
154
  - lib/sample_data_dump/types.rb
147
- - lib/sample_data_dump/use_cases/actor_downloads_sample_data_files.rb
148
- - lib/sample_data_dump/use_cases/actor_dumps_sample_data_to_files.rb
149
- - lib/sample_data_dump/use_cases/actor_loads_sample_data_files.rb
150
- - lib/sample_data_dump/use_cases/actor_uploads_sample_data_files.rb
151
155
  - lib/sample_data_dump/version.rb
152
156
  - sample_data_dump.gemspec
153
157
  homepage: http://www.bellroy.com
data/.rspec_status DELETED
@@ -1,9 +0,0 @@
1
- example_id | status | run_time |
2
- -------------------------------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/duckface/acts_as_interface_spec.rb[1:1:1:1:1] | passed | 0.00232 seconds |
4
- ./spec/duckface/acts_as_interface_spec.rb[1:1:1:1:2] | passed | 0.00333 seconds |
5
- ./spec/lib/sample_data_dump/entities/table_configuration_spec.rb[1:1:1] | passed | 0.00021 seconds |
6
- ./spec/lib/sample_data_dump/use_cases/actor_downloads_sample_data_files_spec.rb[1:1:1] | passed | 0.01413 seconds |
7
- ./spec/lib/sample_data_dump/use_cases/actor_dumps_sample_data_to_files_spec.rb[1:1:1] | passed | 0.00108 seconds |
8
- ./spec/lib/sample_data_dump/use_cases/actor_loads_sample_data_files_spec.rb[1:1:1] | passed | 0.00174 seconds |
9
- ./spec/lib/sample_data_dump/use_cases/actor_uploads_sample_data_files_spec.rb[1:1:1] | passed | 0.001 seconds |
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SampleDataDump
4
- module UseCases
5
- class ActorDownloadsSampleDataFiles
6
- def initialize(persistence)
7
- @persistence = persistence
8
- end
9
-
10
- def result
11
- @persistence.load_table_configurations.fmap do |table_configurations|
12
- result = process_table_configurations_list(table_configurations)
13
- return result if result.failure?
14
- end
15
- end
16
-
17
- private
18
-
19
- def process_table_configurations_list(table_configurations)
20
- results = table_configurations.map do |table_configuration|
21
- result = process_table_configuration(table_configuration)
22
- return result if result.failure?
23
- end
24
- results.last || Dry::Monads::Success(true)
25
- end
26
-
27
- def process_table_configuration(table_configuration)
28
- @persistence.valid?(table_configuration).bind do
29
- @persistence.retrieve_compressed_dump_file_from_central_location(table_configuration)
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SampleDataDump
4
- module UseCases
5
- class ActorDumpsSampleDataToFiles
6
- def initialize(persistence)
7
- @persistence = persistence
8
- end
9
-
10
- def result
11
- @persistence.load_table_configurations.fmap do |table_configurations|
12
- result = process_table_configurations_list(table_configurations)
13
- return result if result.failure?
14
- end
15
- end
16
-
17
- private
18
-
19
- def process_table_configurations_list(table_configurations)
20
- results = table_configurations.map do |table_configuration|
21
- result = process_table_configuration(table_configuration)
22
- return result if result.failure?
23
- end
24
- results.last || Dry::Monads::Success(true)
25
- end
26
-
27
- def process_table_configuration(table_configuration)
28
- @persistence.valid?(table_configuration).bind do
29
- @persistence.dump_and_compress_data_to_local_file(table_configuration)
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SampleDataDump
4
- module UseCases
5
- class ActorLoadsSampleDataFiles
6
- def initialize(persistence)
7
- @persistence = persistence
8
- end
9
-
10
- def result
11
- @persistence.load_table_configurations.fmap do |table_configurations|
12
- result = process_table_configurations_list(table_configurations)
13
- return result if result.failure?
14
- end
15
- end
16
-
17
- private
18
-
19
- def process_table_configurations_list(table_configurations)
20
- table_configurations.reverse_each do |table_configuration|
21
- @persistence.wipe_table(table_configuration)
22
- end
23
-
24
- results = table_configurations.map do |table_configuration|
25
- result = process_table_configuration(table_configuration)
26
- return result if result.failure?
27
- end
28
- results.last || Dry::Monads::Success(true)
29
- end
30
-
31
- def process_table_configuration(table_configuration)
32
- @persistence.valid?(table_configuration).bind do
33
- @persistence.decompress_compressed_dump_file(table_configuration).bind do
34
- @persistence.load_dump_file(table_configuration).bind do
35
- @persistence.reset_sequence(table_configuration)
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SampleDataDump
4
- module UseCases
5
- class ActorUploadsSampleDataFiles
6
- def initialize(persistence)
7
- @persistence = persistence
8
- end
9
-
10
- def result
11
- @persistence.load_table_configurations.fmap do |table_configurations|
12
- result = process_table_configurations_list(table_configurations)
13
- return result if result.failure?
14
- end
15
- end
16
-
17
- private
18
-
19
- def process_table_configurations_list(table_configurations)
20
- results = table_configurations.map do |table_configuration|
21
- result = process_table_configuration(table_configuration)
22
- return result if result.failure?
23
- end
24
- results.last || Dry::Monads::Success(true)
25
- end
26
-
27
- def process_table_configuration(table_configuration)
28
- @persistence.valid?(table_configuration).bind do
29
- @persistence.move_compressed_dump_file_to_central_location(table_configuration)
30
- end
31
- end
32
- end
33
- end
34
- end