Skip to content

Commit

Permalink
clean class.rb federation code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal committed Oct 1, 2024
1 parent f6b3998 commit bff403a
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions lib/ontologies_api_client/models/class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit bff403a

Please sign in to comment.