Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Search federation duplicated results merging issue #830

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
syphax-bouazzouni marked this conversation as resolved.
Show resolved Hide resolved
}
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
Loading