harmonia 0.1.9 → 0.2.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 95a76a4effb5bedd2fb64bd4cb6920702156f0883714c9c323a7aeadb07155ed
|
|
4
|
+
data.tar.gz: 04c8496b78642204612f7cab8da0d71d0c18674113278d0dc78bbf98ee2e1108
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fabbd15f5b2fbea55b88b185ea0eb2f3df2a0053e29d14b22f30f27fbc5fa39096c2bd18085cb611576b50d5bc120f4657e0ad38e8162ccc61d5eaef57818a82
|
|
7
|
+
data.tar.gz: 2e824a79985c5c72650e405dd28a600ce935a49022501fda4bf2aed6c5598bbe0f5afb3cf383137aadbda2b5d88729e28c36d683292af39035961c281edae036
|
|
@@ -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.
|
|
14
|
-
t.
|
|
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
|
|
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
|
|
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
|
|
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,9 +46,10 @@ module Harmonia
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
# Mark sync as completed
|
|
49
|
-
def finish!(records_synced:, records_required:, failed_fm_ids:
|
|
49
|
+
def finish!(records_synced:, records_required:, failed_fm_ids: {}, failed_pg_ids: {})
|
|
50
|
+
status = records_synced == records_required ? 'completed' : 'failed'
|
|
50
51
|
update!(
|
|
51
|
-
status:
|
|
52
|
+
status: status,
|
|
52
53
|
records_synced: records_synced,
|
|
53
54
|
records_required: records_required,
|
|
54
55
|
failed_fm_ids: failed_fm_ids,
|
|
@@ -57,7 +58,7 @@ module Harmonia
|
|
|
57
58
|
end
|
|
58
59
|
|
|
59
60
|
# Mark sync as failed
|
|
60
|
-
def fail!(error_message, failed_fm_ids:
|
|
61
|
+
def fail!(error_message, failed_fm_ids: {}, failed_pg_ids: {})
|
|
61
62
|
update!(
|
|
62
63
|
status: 'failed',
|
|
63
64
|
error_message: error_message,
|