Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions server/lib/reverse_etl/loaders/standard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ def process_individual_records(sync_run, sync, sync_config, activity)

Parallel.each(sync_records, in_threads: concurrency) do |sync_record|
transformer = Transformers::UserMapping.new
Rails.logger.info("Before Transformer, sync_id = #{sync.id}, " \
"sync_run_id = #{sync_run.id}, sync_record = #{sync_record.to_json}")
record = transformer.transform(sync, sync_record)
Rails.logger.info "sync_id = #{sync.id} sync_run_id = #{sync_run.id} sync_record = #{record}"
Rails.logger.info("After Transformer, sync_id = #{sync.id}, sync_run_id = #{sync_run.id}, " \
"sync_record = #{sync_record.to_json}, record = #{record.to_json}")
report = handle_response(client.write(sync_config, [record], sync_record.action), sync_run)
update_sync_record_logs_and_status(report, sync_record)
rescue Activities::LoaderActivity::FullRefreshFailed
raise
rescue StandardError => e
# Utils::ExceptionReporter.report(e, {
# sync_run_id: sync_run.id,
# sync_id: sync.id
# })
Rails.logger.info("Error in Transformer, sync_id = #{sync.id}, " \
"sync_run_id = #{sync_run.id}, sync_record = #{sync_record.to_json} error = #{e.message}")
Rails.logger.error({
error_message: e.message,
sync_run_id: sync_run.id,
Expand Down Expand Up @@ -78,9 +79,11 @@ def process_batch_records(sync_run, sync, sync_config, activity)
rescue Activities::LoaderActivity::FullRefreshFailed
raise
rescue StandardError
# Utils::ExceptionReporter.report(e, {
# sync_run_id: sync_run.id
# })
Rails.logger.info(
"Error in Batch Transformer, " \
"sync_id = #{sync.id}, sync_run_id = #{sync_run.id}, " \
"error = #{e.message}"
)
end
update_sync_records_status(sync_run, successfull_sync_records, failed_sync_records)
heartbeat(activity, sync_run)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ def initialize(chat_history, latest_user_query)
end

def transform
Rails.logger.info("Chat Message Transformer: #{@chat_history.to_json}")
format(PROMPT_USER_TEMPLATE, format_history, @latest_user_query)
rescue StandardError => e
Rails.logger.info(
"Error in Chat Message Transformer, chat_history = #{@chat_history.to_json}, " \
"latest_user_query = #{@latest_user_query.to_json} error = #{e.message}"
)
Rails.logger.error({
error_message: e.message,
chat_history: @chat_history,
Expand Down
10 changes: 10 additions & 0 deletions server/lib/reverse_etl/transformers/user_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class UserMapping < Base

def transform(sync, sync_record)
@mappings = sync.configuration
Rails.logger.info("Mappings Transformer: #{mappings.is_a?(Array)}")
@record = sync_record.record
Rails.logger.info("Record Transformer: #{record}")
@destination_data = {}

if mappings.is_a?(Array)
Expand All @@ -22,6 +24,10 @@ def transform(sync, sync_record)
# sync_id: sync.id,
# sync_record_id: sync_record.id
# })
Rails.logger.info(
"Error in User Mapping Transformer, sync_id = #{sync.id} sync_record_id = #{sync_record.id} " \
"error = #{e.message}"
)
Rails.logger.error({
error_message: e.message,
sync_id: sync.id,
Expand All @@ -32,16 +38,20 @@ def transform(sync, sync_record)
private

def transform_record_v1
Rails.logger.info("Transform record v2: #{mappings.to_json}")
mappings.each do |source_key, dest_path|
Rails.logger.info("Source key: #{source_key}, Dest path: #{dest_path}")
dest_keys = dest_path.split(".")
mapped_destination_value = record[source_key]
extract_destination_mapping(dest_keys, mapped_destination_value)
end
end

def transform_record_v2
Rails.logger.info("Transform record v2: #{mappings.to_json}")
mappings.each do |mapping|
mapping = mapping.with_indifferent_access
Rails.logger.info("Mapping: #{mapping.to_json}")
case mapping[:mapping_type]
when "standard"
standard_mapping(mapping)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
error_message: "Something went wrong",
chat_history:,
latest_user_query:,
<<<<<<< HEAD
stack_trace: ["lib/reverse_etl/transformers/chat_message_transformer.rb:16:in `transform'"]
=======
stack_trace: ["lib/reverse_etl/transformers/chat_message_transformer.rb:18:in `transform'"]
>>>>>>> 105b4c406 (test(CE): enable more logs for error handling (#1763))
}.to_s)
expect(transformer.transform).to be_nil
end
Expand Down
Loading