From bff403ae047171b5ec3718bf7e6eb54828b6bc4c Mon Sep 17 00:00:00 2001 From: Bilel KIHAL Date: Tue, 1 Oct 2024 15:35:24 +0200 Subject: [PATCH] clean class.rb federation code --- lib/ontologies_api_client/models/class.rb | 27 ++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/ontologies_api_client/models/class.rb b/lib/ontologies_api_client/models/class.rb index 20eb20e..898dfc5 100644 --- a/lib/ontologies_api_client/models/class.rb +++ b/lib/ontologies_api_client/models/class.rb @@ -68,26 +68,23 @@ def self.search(*args) params = args.shift || {} params[:q] = query - params[:is_collection] = true raise ArgumentError, "You must provide a search query: Class.search(query: 'melanoma')" if query.nil? || !query.is_a?(String) - if params[:federate] || params[:portals] - search_result = federated_get(params) do |url| - "#{url}/search" - end - merged_collections = {results: [], errors: []} - search_result.each do |result| - if result.collection - merged_collections[:results].concat(result.collection) - elsif result.errors - merged_collections[:errors] << result.errors - end + + search_result = federated_get(params) do |url| + "#{url}/search" + end + merged_collections = {results: [], errors: []} + search_result.each do |result| + if result.collection + merged_collections[:results].concat(result.collection) + elsif result.errors + merged_collections[:errors] << result.errors end - merged_collections - else - HTTP.get("/search", params) end + merged_collections + end def expanded?