Skip to content

Commit

Permalink
add logging for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
wendelfabianchinsamy committed Jan 15, 2025
1 parent 963eec8 commit 970d307
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/models/orcid_affiliation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,12 @@ def push_data(result, _options = {})
end

def self.push_item(item)
Rails.logger.info("[Event Import Worker]: orcid_affiliation push_item")

attributes = item.fetch("attributes", {})
related_identifiers = Array.wrap(attributes.fetch("relatedIdentifiers", nil))
skip_doi = related_identifiers.any? do |related_identifier|
["IsIdenticalTo", "IsPartOf", "IsPreviousVersionOf",
"IsVersionOf"].include?(related_identifier["relatedIdentifierType"])
end
Rails.logger.info("[Event Import Worker]: orcid_affiliation skip_doi = #{skip_doi}")

total_push_items = []

Expand All @@ -70,7 +67,6 @@ def self.push_item(item)
n["nameIdentifierScheme"] == "ORCID"
end
skip_orcid = name_identifier.blank?
Rails.logger.info("[Event Import Worker]: orcid_affiliation skip_orcid = #{skip_orcid}")

affiliation_identifiers = Array.wrap(creator).reduce([]) do |sum, c|
Array.wrap(c["affiliation"]).each do |a|
Expand All @@ -80,8 +76,6 @@ def self.push_item(item)
sum
end

Rails.logger.info("[Event Import Worker]: orcid_affiliation aff_identifiers = #{affiliation_identifiers}")

return nil if affiliation_identifiers.blank? || skip_doi || skip_orcid

subj_id = normalize_orcid(name_identifier["nameIdentifier"])
Expand Down Expand Up @@ -112,6 +106,8 @@ def self.push_item(item)
ssum
end

Rails.logger.info("[Event Import Worker]: send orcid aff push_items = #{push_items.inspect}")

# there can be one or more affiliation_identifier per DOI
Array.wrap(push_items).each do |iiitem|
data = {
Expand All @@ -133,6 +129,8 @@ def self.push_item(item)
},
}

Rails.logger.info("[Event Import Worker]: send orcid aff to events")
Rails.logger.info("[Event Import Worker]: orcid data = #{data.inspect}")
send_event_import_message(data)

Rails.logger.info "[Event Data] #{iiitem['subj_id']} #{iiitem['relation_type_id']} #{iiitem['obj_id']} sent to the events queue."
Expand Down

0 comments on commit 970d307

Please sign in to comment.