From 9f0fee89da72ef8a9b0304a483039d10a62e6197 Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Mon, 25 Nov 2024 19:07:13 +0100 Subject: [PATCH 1/2] include non canonical portals in counting results for each portal --- app/helpers/federation_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/helpers/federation_helper.rb b/app/helpers/federation_helper.rb index 6b52b7a6b..4fc0c086a 100644 --- a/app/helpers/federation_helper.rb +++ b/app/helpers/federation_helper.rb @@ -221,7 +221,9 @@ def federated_search_counts(search_results) end def federated_browse_counts(ontologies) - ids = ontologies.map { |ontology| ontology[:id] } + ids = ontologies.flat_map do |ontology| + [ontology[:id]] + (ontology[:sources] || []) + end.uniq counts_ontology_ids_by_portal_name(ids) end From 5f460ffc76249688fb4b0397e2997dc31cc2d2ec Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Mon, 25 Nov 2024 19:36:34 +0100 Subject: [PATCH 2/2] include non canonical portals in counting results for each portal in federated search --- app/helpers/federation_helper.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/helpers/federation_helper.rb b/app/helpers/federation_helper.rb index 4fc0c086a..f6ad775ca 100644 --- a/app/helpers/federation_helper.rb +++ b/app/helpers/federation_helper.rb @@ -214,9 +214,11 @@ def init_federation_portals_status end def federated_search_counts(search_results) - ids = search_results.map do |result| - result.dig(:root, :ontology_id) || rest_url - end + ids = search_results.flat_map do |result| + ontology_id = result.dig(:root, :ontology_id) || rest_url + other_portal_ids = result.dig(:root, :other_portals)&.map { |portal| portal[:link].split('?').first } || [] + [ontology_id] + other_portal_ids + end.uniq counts_ontology_ids_by_portal_name(ids) end @@ -236,7 +238,7 @@ def counts_ontology_ids_by_portal_name(portals_ids) counts[current_portal.downcase] += 1 if id.include?(current_portal.to_s.downcase) federation_portals.each do |portal| - portal_api = federated_portals[portal.downcase.to_sym][:api] + portal_api = federated_portals[portal.downcase.to_sym][:name].downcase counts[portal.downcase] += 1 if id.include?(portal_api) end end