multiwoven-integrations 0.1.73 → 0.1.75

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
  SHA256:
3
- metadata.gz: c9f12b6e7ed8927ea4dd1606ebc668286c0f8b594de8f21a95940a3e7d6186c3
4
- data.tar.gz: 37689ed52ff9cb8ae8eed14aec908d725f2f43c1a8ac1ea29ffba6d62f7c9ea1
3
+ metadata.gz: ae5784806bc5de9222274f6a03be3883720e308f1e0922a76a588f5e582112fb
4
+ data.tar.gz: 065a346c9beebf746e1e8d6d4a7b49d76c01185005269df442e58719933ca9f4
5
5
  SHA512:
6
- metadata.gz: 876998f9a9b1194db9f2017326f7fdf813715538fdd4dd21973717f786fe5c5d0b0929aab4296f13c83861cace0f12c18ad97ec7983964b655388b45a30294e8
7
- data.tar.gz: bf09fe09f534b40640a7c0a783868a90aba97c1ba17fdebc17f931b784f754fe4eb03ceaf764bf81bbd64de5f9beb2b1358b36e3607886059bc7140e5327f9b1
6
+ metadata.gz: 00fa3449d0395073e4b5277d105b5331c19e4290e9a8972baa80bc80aeee6ef63effcf94bc0484ced2ea79bb33900467bd2a68ee85b8a8d2796af317a9ef9340
7
+ data.tar.gz: 263e855471164f79df4acafb32116b752cd3945d2439fc29eea4540ee2c6360d80d472caf2996475a4b3398a68d0361d907e2f5a8844ca4f2cd123da02706155
@@ -5,7 +5,7 @@ module Multiwoven
5
5
  class DestinationConnector < BaseConnector
6
6
  # Records are transformed json payload send it to the destination
7
7
  # SyncConfig is the Protocol::SyncConfig object
8
- def write(_sync_config, _records, _action = "insert")
8
+ def write(_sync_config, _records, _action = "destination_insert")
9
9
  raise "Not implemented"
10
10
  # return Protocol::TrackingMessage
11
11
  end
@@ -3,7 +3,7 @@
3
3
  module Multiwoven
4
4
  module Integrations::Core
5
5
  module Fullrefresher
6
- def write(sync_config, records, action = "insert")
6
+ def write(sync_config, records, action = "destination_insert")
7
7
  if sync_config && sync_config.sync_mode == "full_refresh" && !@full_refreshed
8
8
  response = clear_all_records(sync_config)
9
9
  return response unless response &&
@@ -3,16 +3,22 @@
3
3
  module Multiwoven
4
4
  module Integrations::Core
5
5
  class QueryBuilder
6
+ include Utils
7
+
6
8
  def self.perform(action, table, record, primary_key = nil)
7
9
  case action.downcase
8
- when "insert"
10
+ when "destination_insert"
9
11
  columns = record.keys.join(", ")
10
12
  values = record.values.map { |value| "'#{value}'" }.join(", ")
11
13
  # TODO: support bulk insert
12
14
  "INSERT INTO #{table} (#{columns}) VALUES (#{values});"
13
- when "update"
15
+ when "destination_update"
14
16
  # Ensure primary key is a string and exists within record for the WHERE clause
15
- return "Primary key '#{primary_key}' not found in record." if record[primary_key].nil?
17
+ if record[primary_key].nil?
18
+ error_message = "Primary key '#{primary_key}' not found in record."
19
+ Integrations::Service.logger.error(error_message)
20
+ return error_message
21
+ end
16
22
 
17
23
  primary_key_value = record.delete(primary_key) # Remove and return the primary key value
18
24
  set_clause = record.map { |key, value| "#{key} = '#{value}'" }.join(", ")
@@ -3,7 +3,7 @@
3
3
  module Multiwoven
4
4
  module Integrations::Core
5
5
  module RateLimiter
6
- def write(sync_config, records, action = "insert")
6
+ def write(sync_config, records, action = "destination_insert")
7
7
  stream = sync_config.stream
8
8
 
9
9
  @queue ||= Limiter::RateQueue.new(stream.request_rate_limit, interval: stream.rate_limit_unit_seconds) do
@@ -35,7 +35,7 @@ module Multiwoven::Integrations::Destination
35
35
  })
36
36
  end
37
37
 
38
- def write(sync_config, records, _action = "insert")
38
+ def write(sync_config, records, _action = "destination_insert")
39
39
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
40
40
  access_token = connection_config[:access_token]
41
41
  url = generate_url(sync_config, connection_config)
@@ -31,7 +31,7 @@ module Multiwoven::Integrations::Destination
31
31
  })
32
32
  end
33
33
 
34
- def write(sync_config, records, _action = "insert")
34
+ def write(sync_config, records, _action = "destination_insert")
35
35
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
36
36
  connection_config = connection_config.with_indifferent_access
37
37
  url = sync_config.stream.url
@@ -42,16 +42,17 @@ module Multiwoven::Integrations::Destination
42
42
  db&.close
43
43
  end
44
44
 
45
- def write(sync_config, records, action = "insert")
45
+ def write(sync_config, records, action = "destination_insert")
46
46
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
47
47
  table_name = sync_config.stream.name
48
+ primary_key = sync_config.model.primary_key
48
49
  db = create_connection(connection_config)
49
50
 
50
51
  write_success = 0
51
52
  write_failure = 0
52
53
 
53
54
  records.each do |record|
54
- query = Multiwoven::Integrations::Core::QueryBuilder.perform(action, table_name, record)
55
+ query = Multiwoven::Integrations::Core::QueryBuilder.perform(action, table_name, record, primary_key)
55
56
  logger.debug("POSTGRESQL:WRITE:QUERY query = #{query} sync_id = #{sync_config.sync_id} sync_run_id = #{sync_config.sync_run_id}")
56
57
  begin
57
58
  db.exec(query)
@@ -36,7 +36,7 @@ module Multiwoven::Integrations::Destination
36
36
  })
37
37
  end
38
38
 
39
- def write(sync_config, records, _action = "insert")
39
+ def write(sync_config, records, _action = "destination_insert")
40
40
  @sync_config = sync_config
41
41
  connection_config = sync_config.destination.connection_specification.with_indifferent_access
42
42
  file_path = generate_file_path(sync_config)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.1.73"
5
+ VERSION = "0.1.75"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.73
4
+ version: 0.1.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-29 00:00:00.000000000 Z
11
+ date: 2024-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport