Skip to content

Commit

Permalink
possible fix for missing bib_udf_tb03 in reftracker response
Browse files Browse the repository at this point in the history
  • Loading branch information
jambun committed Nov 28, 2024
1 parent 9e032ae commit 5d7ca76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/model/reftracker_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def self.manuscript_offers(page = 1, offer_number)
# here's how accession.identifier looks in the db :(
# ["moo",null,null,null]
# NLA only uses id_0 so this works
offer_ids = offers.map{|offer| offer['bib_udf_tb03']}.select{|id| !id.empty?}.map{|id| '["' + id + '",null,null,null]'}.compact
offer_ids = offers.map{|offer| offer.fetch('bib_udf_tb03', '')}.select{|id| !id.empty?}.map{|id| '["' + id + '",null,null,null]'}.compact

# find out which of the offer_ids already exist in AS
found_ids = nil
DB.open{ |db| found_ids = db[:accession].filter(:identifier => offer_ids).select(:identifier).map{|i| ASUtils.json_parse(i[:identifier]).first}}

# then filter out the found ids, and any offers without an id
offers.select{|offer| !offer['bib_udf_tb03'].empty? && !found_ids.include?(offer['bib_udf_tb03'])}
offers.select{|offer| !offer.fetch('bib_udf_tb03', '').empty? && !found_ids.include?(offer['bib_udf_tb03'])}
.map do |offer|
offer['question_text_stripped'] = strip_markup(offer['question_text'])
if offer['question_text_stripped'].length > 400
Expand Down

0 comments on commit 5d7ca76

Please sign in to comment.