From dc2bb130f453f98abf06c3bd9b51864a0036f6fe Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Thu, 14 Nov 2024 11:35:58 +0100 Subject: [PATCH] Fix: notes and zombie mappings class label fetching and optimize concept 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 --- app/controllers/concepts_controller.rb | 8 ++++++-- app/helpers/mappings_helper.rb | 14 ++++---------- app/views/notes/_note_line.html.haml | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/controllers/concepts_controller.rb b/app/controllers/concepts_controller.rb index c52bbcf88..3d4923296 100644 --- a/app/controllers/concepts_controller.rb +++ b/app/controllers/concepts_controller.rb @@ -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) diff --git a/app/helpers/mappings_helper.rb b/app/helpers/mappings_helper.rb index 09b2c4d67..129b1e4bf 100644 --- a/app/helpers/mappings_helper.rb +++ b/app/helpers/mappings_helper.rb @@ -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("#{cls_label}") + cls_link = raw("#{cls_label}") ont_name = target_concept.links['ontology'] ont_link = link_to ExternalLinkTextComponent.new(text: ont_name).call, target_concept.links['ontology'], target: '_blank' diff --git a/app/views/notes/_note_line.html.haml b/app/views/notes/_note_line.html.haml index ac2909951..6a12aff5f 100644 --- a/app/views/notes/_note_line.html.haml +++ b/app/views/notes/_note_line.html.haml @@ -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") \ No newline at end of file