diff --git a/app/helpers/federation_helper.rb b/app/helpers/federation_helper.rb index 6b52b7a6b..f6ad775ca 100644 --- a/app/helpers/federation_helper.rb +++ b/app/helpers/federation_helper.rb @@ -214,14 +214,18 @@ 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 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 @@ -234,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