Skip to content

Commit

Permalink
Fix issue with using dig
Browse files Browse the repository at this point in the history
  • Loading branch information
susannasiebert committed May 10, 2024
1 parent 5a7cec2 commit abe0687
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/app/models/my_disease_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def parse_response(resp)

do_def, do_def_citations = process_do_def(data.dig('def'))

mondo_data = p['hits'][0].dig('mondo')
mondo_def = process_mondo_def(mondo_data)
mondo_def = process_mondo_def(p)

return {
'disease_ontology_exact_synonyms': Array(data.dig('synonyms', 'exact')),
Expand All @@ -44,7 +43,7 @@ def parse_response(resp)
'do_def': do_def,
'do_def_citations': do_def_citations,
'mondo_def': mondo_def,
'mondo_id': mondo_data.dig('mondo')
'mondo_id': p['hits'][0].dig('mondo', 'mondo')
}
end

Expand Down Expand Up @@ -77,8 +76,8 @@ def cache_key(disease)
"my_disease_info_#{disease.id}_#{disease.updated_at}"
end

def process_mondo_def(mondo_data)
if md = mondo_data.dig('definition')
def process_mondo_def(p)
if md = p['hits'][0].dig('mondo', 'definition')
md.gsub(/\[(.+)\]/, '').strip
else
nil
Expand Down

0 comments on commit abe0687

Please sign in to comment.