Skip to content

Commit

Permalink
include non canonical portals in counting results for each portal in …
Browse files Browse the repository at this point in the history
…federated search
  • Loading branch information
Bilelkihal committed Nov 25, 2024
1 parent 9f0fee8 commit 5f460ff
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/helpers/federation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 5f460ff

Please sign in to comment.