Skip to content

Commit

Permalink
Merge branch 'fix/incorrect-federation-result-count' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Nov 25, 2024
2 parents 99c7dfe + 5f460ff commit 4d9b0fb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/helpers/federation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit 4d9b0fb

Please sign in to comment.