harmonia 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20a7d4c57e312c17c812acfaa1d4f31234d291265b0da78cfdfc94037dcd6bc4
4
- data.tar.gz: 93288d73a82f3e86f6e5e9130102beeb5db563c5b192c6d981ea9c2c7e79ac68
3
+ metadata.gz: 28c0e7e7f87cdbf680cb961b01ef7f599af2c662bebe3c8dd857db2b172e43d6
4
+ data.tar.gz: 6355cba5ee75d3fcca62040079a70342f72bc6f13ca6554d8671b9af53d0218a
5
5
  SHA512:
6
- metadata.gz: 0da52f204c3f7a03af63ad177a81a79e710e2eb4c5f50f47046ab36eca2afbcf9cd26bd3bea03ecf6ff58a0f4e52c82e98e025d777c339d4bb8b03ed4af66cf0
7
- data.tar.gz: 7b6526bbfafa4a0f732d51bf287313e5ceb7f4f7590e99d115f1f1e48eb0c4691d1a1ad84e6bac5acf5153c59cc57e7fefed665de7e1f2c269c548d22a6af543
6
+ metadata.gz: b258047a77289e9b4dc8c9e5de0096359a927f761bfee5c02105854973b7afa6314e1d1b8496dc1e0bac73c023e373d14562041bb57a3eac6105736d1888f330
7
+ data.tar.gz: c485199ad2448e3810dc3c09dda6f73b71a55dd17ec4be924cf5d49483f7761dbbb2465b8cafb67adf5c104a46f45dded59ef34aa630cf02b915bef0c34c0e5e
@@ -32,7 +32,10 @@ module Harmonia
32
32
 
33
33
  desc 'sync #{table_name} from ActiveRecord to FileMaker'
34
34
  task #{task_name}: :environment do
35
- #{class_name}ToFileMakerSyncer.new.sync
35
+ dbc = DatabaseConnector.new
36
+
37
+ syncer = #{class_name}Syncer.new(dbc)
38
+ syncer.run
36
39
  end
37
40
  TASK
38
41
 
@@ -58,7 +58,10 @@ module Harmonia
58
58
 
59
59
  desc 'sync #{table_name} from FileMaker to ActiveRecord'
60
60
  task #{task_name}: :environment do
61
- #{class_name}Syncer.new.sync
61
+ dbc = DatabaseConnector.new
62
+
63
+ syncer = #{class_name}Syncer.new(dbc)
64
+ syncer.run
62
65
  end
63
66
  TASK
64
67
 
@@ -10,8 +10,8 @@ class CreateHarmoniaSyncs < ActiveRecord::Migration[<%= Rails::VERSION::MAJOR %>
10
10
  t.string :status, default: 'pending'
11
11
  t.string :direction
12
12
  t.text :error_message
13
- t.string :failed_fm_ids, array: true
14
- t.integer :failed_pg_ids, array: true
13
+ t.jsonb :failed_fm_ids, default: {}
14
+ t.jsonb :failed_pg_ids, default: {}
15
15
 
16
16
  t.timestamps
17
17
  end
@@ -6,8 +6,8 @@ class <%= class_name %>Syncer
6
6
  def initialize(database_connector)
7
7
  @database_connector = database_connector
8
8
  @last_synced_on = Harmonia::Sync.last_sync_for('<%= table_name %>', 'FileMaker to ActiveRecord')&.ran_on || (Time.now - 15.year)
9
- @failed_fm_ids = []
10
- @failed_pg_ids = []
9
+ @failed_fm_ids = {}
10
+ @failed_pg_ids = {}
11
11
  end
12
12
 
13
13
  # Main sync method
@@ -119,7 +119,7 @@ class <%= class_name %>Syncer
119
119
  <%= class_name %>.create!(attributes)
120
120
  success_count += 1
121
121
  rescue StandardError => e
122
- @failed_fm_ids << trophonius_record.record_id
122
+ @failed_fm_ids[trophonius_record.record_id.to_s] = e.message
123
123
  Rails.logger.error("Failed to create record from FileMaker ID #{trophonius_record.record_id}: #{e.message}")
124
124
  end
125
125
  end
@@ -142,7 +142,7 @@ class <%= class_name %>Syncer
142
142
  )
143
143
  success_count += 1
144
144
  rescue StandardError => e
145
- @failed_fm_ids << trophonius_record.record_id
145
+ @failed_fm_ids[trophonius_record.record_id.to_s] = e.message
146
146
  Rails.logger.error("Failed to update record from FileMaker ID #{trophonius_record.record_id}: #{e.message}")
147
147
  end
148
148
  end
@@ -158,7 +158,7 @@ class <%= class_name %>Syncer
158
158
  begin
159
159
  <%= class_name %>.where(id: pg_id).destroy_all
160
160
  rescue StandardError => e
161
- @failed_pg_ids << pg_id
161
+ @failed_pg_ids[pg_id.to_s] = e.message
162
162
  Rails.logger.error("Failed to delete record with PostgreSQL ID #{pg_id}: #{e.message}")
163
163
  end
164
164
  end
@@ -46,7 +46,7 @@ module Harmonia
46
46
  end
47
47
 
48
48
  # Mark sync as completed
49
- def finish!(records_synced:, records_required:, failed_fm_ids: [], failed_pg_ids: [])
49
+ def finish!(records_synced:, records_required:, failed_fm_ids: {}, failed_pg_ids: {})
50
50
  status = records_synced == records_required ? 'completed' : 'failed'
51
51
  update!(
52
52
  status: status,
@@ -58,7 +58,7 @@ module Harmonia
58
58
  end
59
59
 
60
60
  # Mark sync as failed
61
- def fail!(error_message, failed_fm_ids: [], failed_pg_ids: [])
61
+ def fail!(error_message, failed_fm_ids: {}, failed_pg_ids: {})
62
62
  update!(
63
63
  status: 'failed',
64
64
  error_message: error_message,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harmonia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kempen Automatisering