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

Feature: implement ontology agents endpoint #84

Merged
merged 6 commits into from
Jul 23, 2024
18 changes: 18 additions & 0 deletions controllers/agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
reply agents
end

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

Check warning on line 31 in controllers/agents_controller.rb

View check run for this annotation

Codecov / codecov/patch

controllers/agents_controller.rb#L26-L31

Added lines #L26 - L31 were not covered by tests
end

agents = properties_agents.values.flatten.uniq {|x| x.id }

Check warning on line 34 in controllers/agents_controller.rb

View check run for this annotation

Codecov / codecov/patch

controllers/agents_controller.rb#L34

Added line #L34 was not covered by tests

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

Check warning on line 37 in controllers/agents_controller.rb

View check run for this annotation

Codecov / codecov/patch

controllers/agents_controller.rb#L36-L37

Added lines #L36 - L37 were not covered by tests
end

reply agents

Check warning on line 40 in controllers/agents_controller.rb

View check run for this annotation

Codecov / codecov/patch

controllers/agents_controller.rb#L40

Added line #L40 was not covered by tests
end

# Display a single agent
get '/:id' do
check_last_modified_collection(LinkedData::Models::Agent)
Expand Down
Loading