multiwoven-integrations 0.1.48 → 0.1.49

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: f070f9727eba1e360878e33850045dfe4b508f351d91cb6fa3e6ae46edda8ad7
4
- data.tar.gz: 425485c695c2803835c98549695d343d63db2c5d388328dc983759a50fdd63ee
3
+ metadata.gz: 96d535997b9e775eb4f677ba0be5722ee3aaa88f3226a6fa3b4aef24fb949ffe
4
+ data.tar.gz: a1c0be33b6c70efadb6c4bed8016a8b8c65cbb66ef430194d50cd0220b325559
5
5
  SHA512:
6
- metadata.gz: ae737e08dbae12d4cea2c51082684f5dcfa1d50d75100252bcaaf3171922d185072ad5894a9546f695a22b3b8112b176fb8f6a1d9caa3a8614240243188373a8
7
- data.tar.gz: 7d1adab5630abc8fb506391f49476b285f6753f79f8b779bf87db87ffb918c5e794dba28ee419b19629ea6f87ed93040bd81af787e92fc02f2cebef6d058dfd1
6
+ metadata.gz: 406892b62ca959ec83fd237568a6d5475f51656d1083b54ac87ff1c08a4cbb49ffc5eca436694e30514c6280cbb943ad8b66f894cb549d4241bacb6e10895fd3
7
+ data.tar.gz: bc3bf83c198472ef8af07f6763a02e31b8abc7742bf3b5f0fff3483094526870f88ad5f88df6291301eec3e207541e62a84d249f6c5df861ffc7debdea35db18
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.1.48"
5
+ VERSION = "0.1.49"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -47,10 +47,10 @@ module Multiwoven
47
47
  # To overcome this, we need a cursor-based pagination strategy instead of relying on OFFSET.
48
48
  # query = batched_query(query, sync_config.limit, sync_config.offset) unless sync_config.limit.nil? && sync_config.offset.nil?
49
49
  query = sync_config.model.query
50
- exclude_keys = ["attributes"]
50
+ query = batched_query(query, sync_config.limit, sync_config.offset) unless sync_config.limit.nil? && sync_config.offset.nil?
51
51
  queried_data = @client.query(query)
52
52
  results = queried_data.map do |record|
53
- record.reject { |key, _| exclude_keys.include?(key) }
53
+ flatten_nested_hash(record)
54
54
  end
55
55
  results.map do |row|
56
56
  RecordMessage.new(data: row, emitted_at: Time.now.to_i).to_multiwoven_message
@@ -62,16 +62,27 @@ module Multiwoven
62
62
  private
63
63
 
64
64
  def query(connection, query)
65
- exclude_keys = ["attributes"]
66
65
  queried_data = connection.query(query)
66
+
67
67
  results = queried_data.map do |record|
68
- record.reject { |key, _| exclude_keys.include?(key) }
68
+ flatten_nested_hash(record)
69
69
  end
70
70
  results.map do |row|
71
71
  RecordMessage.new(data: row, emitted_at: Time.now.to_i).to_multiwoven_message
72
72
  end
73
73
  end
74
74
 
75
+ def flatten_nested_hash(record, prefix = nil)
76
+ record = record.reject { |key, _| key == "attributes" }
77
+ record.flat_map do |key, value|
78
+ if value.is_a?(Hash)
79
+ flatten_nested_hash(value, prefix ? "#{prefix}_#{key}" : key)
80
+ else
81
+ { prefix ? "#{prefix}_#{key}" : key => value }
82
+ end
83
+ end.reduce({}, :merge)
84
+ end
85
+
75
86
  def create_connection(connection_config)
76
87
  initialize_client(connection_config)
77
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.48
4
+ version: 0.1.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P