Skip to content

Commit

Permalink
return a list of uniq values, for the endpoint '/ontologies/:acronym/…
Browse files Browse the repository at this point in the history
…agents' that contains all the agents of the ontology using agents_attrs list
  • Loading branch information
Bilelkihal committed Jul 16, 2024
1 parent 2eded90 commit b89ae7c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions controllers/agents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
class AgentsController < ApplicationController

# Ontology agents
get '/ontologies/:acronym/agents' do
ont = Ontology.find(params["acronym"]).first
latest = ont.latest_submission(status: :any)
latest.bring(OntologySubmission.agents_attrs)
latest.bring(*OntologySubmission.agents_attrs)
properties_agents= {}
OntologySubmission.agents_attrs.each do |attr|
properties_agents[attr] = Array(latest.send(attr))
end

agents = properties_agents.values.flatten.uniq {|x| x.id }
agents = []
properties_agents.each do |key, value|
agents.concat(value.map{ |agent| agent.bring_remaining})
end
agents.uniq!

if includes_param.include?(:all) || includes_param.include?(:usages)
LinkedData::Models::Agent.load_agents_usages(agents)
Expand Down

0 comments on commit b89ae7c

Please sign in to comment.