Skip to content

Commit

Permalink
Fix: notes and zombie mappings class label fetching and optimize conc…
Browse files Browse the repository at this point in the history
…ept mapping table API calls (#842)

* fix label ajax for no more existent ontologies

* use label fetched for classes in the notes table

* optimize the calls done for the concept mapping table

* fix home page bubbles if no analytics enabled
  • Loading branch information
syphax-bouazzouni authored Nov 14, 2024
1 parent 17ed0b6 commit dc2bb13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 6 additions & 2 deletions app/controllers/concepts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ def index
def show_label
cls_id = params[:concept] || params[:id]
ont_id = params[:ontology]
pref_label = concept_label(ont_id, cls_id)
cls = @ontology.explore.single_class({ language: request_lang, include: 'prefLabel' }, cls_id)
pref_label = begin
concept_label(ont_id, cls_id)
rescue
cls_id
end
cls = @ontology.explore&.single_class({ language: request_lang, include: 'prefLabel' }, cls_id)
label = helpers.main_language_label(pref_label)
link = concept_path(cls_id, ont_id, request_lang)

Expand Down
14 changes: 4 additions & 10 deletions app/helpers/mappings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,18 @@ def mapping_links(mapping, concept)
process = mapping.process || {}

if inter_portal_mapping?(target_concept)
cls_link = ajax_to_inter_portal_cls(target_concept)
cls_link = target_concept.id
ont_name = target_concept.links['ontology']
ont_link = link_to ont_name, get_inter_portal_ui_link(ont_name, process['name']), target: '_blank'
source_tooltip = 'Internal-portal'
elsif internal_mapping?(target_concept)
begin
ont = target_concept.explore.ontology
ont_name = ont.acronym
ont_link = link_to ont_name, ontology_path(ont_name), 'data-turbo-frame': '_top'
rescue
ont_name = target_concept.links['ontology'] || target_concept.id
ont_link = ont_name
end
ont_name = target_concept.links['ontology'].split('/').last
ont_link = link_to ont_name, ontology_path(ont_name), 'data-turbo-frame': '_top'
cls_link = raw(get_link_for_cls_ajax(target_concept.id, ont_name, '_top'))
source_tooltip = 'Internal'
else
cls_label = ExternalLinkTextComponent.new(text: target_concept.links['self']).call
cls_link = raw("<a href='#{target_concept.links["self"]}' target='_blank'>#{cls_label}</a>")
cls_link = raw("<a href='#{target_concept.links['self']}' target='_blank'>#{cls_label}</a>")
ont_name = target_concept.links['ontology']
ont_link = link_to ExternalLinkTextComponent.new(text: ont_name).call, target_concept.links['ontology'],
target: '_blank'
Expand Down
2 changes: 1 addition & 1 deletion app/views/notes/_note_line.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
- if parent_type.eql?('ontology')
- row.td do
- if note.relatedClass && note.relatedClass.length > 0
%a{href: "/ontologies/#{ontology_acronym}?p=classes&conceptid=#{CGI.escape(note.relatedClass.first)}", 'data-turbo': 'false'}= note.relatedClass.first
= get_link_for_cls_ajax(note.relatedClass.first, ontology_acronym, '_top')
- row.td do
= DateTime.parse(note.created).strftime("%Y-%m-%d")

0 comments on commit dc2bb13

Please sign in to comment.