Skip to content

Commit

Permalink
Fix: Search federation duplicated results merging issue (#830)
Browse files Browse the repository at this point in the history
* replace unexisting key :ontology_acronym and get the ontology acronym from the ontology_id when checking ontology duplication in federation

* clean code of merge federated results method
  • Loading branch information
Bilelkihal authored Nov 7, 2024
1 parent b7318e0 commit a9dd3b7
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions app/controllers/concerns/search_aggregator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,15 @@ def blacklist_cls_id_components(cls_id, blacklist_words)
def merge_federated_results(search_results)
search_results.each do |element|
element[:root][:other_portals] = []

element[:reuses].reject! do |reuse|
if (element[:root][:ontology_acronym] == reuse[:root][:ontology_acronym]) && (element[:root][:uri] == reuse[:root][:uri])
portal_name = reuse[:root][:portal_name]
link = reuse[:root][:link]
element[:root][:other_portals] << {
name: portal_name,
color: federated_portal_color(portal_name),
light_color: federated_portal_light_color(portal_name),
link: link,
ontology_id: reuse[:root][:ontology_id]
}
element_ontology_id = element[:root][:ontology_id].split('/').last
element_uri = element[:root][:uri]
reuse_ontology_id = reuse[:root][:ontology_id].split('/').last
reuse_uri = reuse[:root][:uri]

if element_ontology_id == reuse_ontology_id && element_uri == reuse_uri
element[:root][:other_portals] << build_other_portal_entry(reuse)
true
else
false
Expand All @@ -270,6 +268,16 @@ def merge_federated_results(search_results)
end
end

def build_other_portal_entry(reuse)
{
name: reuse[:root][:portal_name],
color: federated_portal_color(reuse[:root][:portal_name]),
light_color: federated_portal_light_color(reuse[:root][:portal_name]),
link: reuse[:root][:link],
ontology_id: reuse[:root][:ontology_id]
}
end

def swap_canonical_portal_results_first(search_results)
all_submissions = LinkedData::Client::Models::OntologySubmission.all(include: 'pullLocation', include_views: true, display_links: false, display_context: false)

Expand Down

0 comments on commit a9dd3b7

Please sign in to comment.