Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into feature/add-on…
Browse files Browse the repository at this point in the history
…toportal-api-configs
  • Loading branch information
syphax-bouazzouni committed Aug 8, 2024
2 parents 9254153 + e9d1db6 commit 13bd205
Show file tree
Hide file tree
Showing 10 changed files with 290 additions and 94 deletions.
34 changes: 15 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: f0098d7030541cf65e29f898c3315e2a2b9df95e
revision: 552fbe5faed5bb195396251066ef0e7b930939a0
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -121,7 +121,7 @@ GEM
i18n
rake (>= 10.0.0)
sshkit (>= 1.9.0)
capistrano-bundler (2.1.0)
capistrano-bundler (2.1.1)
capistrano (~> 3.1)
capistrano-locally (0.3.0)
capistrano (~> 3.0)
Expand All @@ -138,7 +138,7 @@ GEM
dante (0.2.0)
date (3.3.4)
declarative (0.0.20)
docile (1.4.0)
docile (1.4.1)
domain_name (0.6.20240107)
ed25519 (1.3.0)
faraday (1.10.3)
Expand All @@ -164,7 +164,7 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.16.3)
ffi (1.17.0)
gapic-common (0.21.1)
faraday (>= 1.9, < 3.a)
faraday-retry (>= 1.0, < 3.a)
Expand All @@ -178,27 +178,26 @@ GEM
google-analytics-data (0.6.0)
google-analytics-data-v1beta (>= 0.11, < 2.a)
google-cloud-core (~> 1.6)
google-analytics-data-v1beta (0.12.0)
google-analytics-data-v1beta (0.13.0)
gapic-common (>= 0.21.1, < 2.a)
google-cloud-errors (~> 1.0)
google-apis-analytics_v3 (0.16.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-core (0.15.0)
google-apis-core (0.15.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 1.9)
httpclient (>= 2.8.1, < 3.a)
httpclient (>= 2.8.3, < 3.a)
mini_mime (~> 1.0)
mutex_m
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
google-cloud-core (1.7.0)
google-cloud-core (1.7.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.1.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-protobuf (3.25.3)
google-protobuf (3.25.3-x86_64-linux)
google-protobuf (3.25.4)
googleapis-common-protos (1.6.0)
google-protobuf (>= 3.18, < 5.a)
googleapis-common-protos-types (~> 1.7)
Expand All @@ -212,16 +211,13 @@ GEM
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
grpc (1.65.1)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.65.1-x86_64-linux)
grpc (1.65.2-x86_64-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
haml (5.2.2)
temple (>= 0.8.0)
tilt
hashdiff (1.1.0)
hashdiff (1.1.1)
htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.6)
Expand Down Expand Up @@ -251,14 +247,15 @@ GEM
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0702)
mime-types-data (3.2024.0806)
mini_mime (1.1.5)
minitest (4.7.5)
minitest-stub_any_instance (1.0.3)
mlanett-redis-lock (0.2.7)
redis
multi_json (1.15.0)
multipart-post (2.4.1)
mutex_m (0.2.0)
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
net-imap (0.4.14)
Expand Down Expand Up @@ -344,7 +341,7 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.3.2)
rexml (3.3.4)
strscan
rsolr (2.6.0)
builder (>= 2.1.2)
Expand Down Expand Up @@ -409,7 +406,6 @@ GEM
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
Expand Down
29 changes: 25 additions & 4 deletions controllers/agents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
class AgentsController < ApplicationController

%w[/agents /Agents].each do |namespace|
namespace namespace do
# Display all agents
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))
end

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)
end

reply agents
end

%w[agents Agents].each do |namespace|
namespace "/#{namespace}" do
get do
check_last_modified_collection(LinkedData::Models::Agent)
query = LinkedData::Models::Agent.where
Expand Down Expand Up @@ -147,4 +168,4 @@ def update_agent(agent, params)
end
end

end
end
4 changes: 4 additions & 0 deletions controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ class HomeController < ApplicationController
expires 3600, :public
last_modified @@root_last_modified ||= Time.now.httpdate
routes = routes_list

#TODO: delete when ccv will be on production
routes.delete("/ccv")
if LinkedData.settings.enable_resource_index == false
routes.delete("/resource_index")
end

routes.delete('/Agents')

routes_hash = {}
context = {}
routes.each do |route|
Expand Down
12 changes: 6 additions & 6 deletions controllers/properties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PropertiesController < ApplicationController
get '/:property' do
prop = params[:property]
ont, submission = get_ontology_and_submission
p = ont.property(prop, submission)
p = ont.property(prop, submission, display_all_attributes: false)
error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil?
reply 200, p
end
Expand All @@ -51,7 +51,7 @@ class PropertiesController < ApplicationController
get '/:property/tree' do
prop = params[:property]
ont, submission = get_ontology_and_submission
p = ont.property(prop, submission)
p = ont.property(prop, submission, display_all_attributes: false)
error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil?
root_tree = p.tree

Expand Down Expand Up @@ -79,7 +79,7 @@ class PropertiesController < ApplicationController
get '/:property/ancestors' do
prop = params[:property]
ont, submission = get_ontology_and_submission
p = ont.property(prop, submission)
p = ont.property(prop, submission, display_all_attributes: false)
error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil?
ancestors = p.ancestors
p.class.in(submission).models(ancestors).include(:label, :definition).all
Expand All @@ -91,7 +91,7 @@ class PropertiesController < ApplicationController
get '/:property/descendants' do
prop = params[:property]
ont, submission = get_ontology_and_submission
p = ont.property(prop, submission)
p = ont.property(prop, submission, display_all_attributes: false)
error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil?
descendants = p.descendants
p.class.in(submission).models(descendants).include(:label, :definition).all
Expand All @@ -103,7 +103,7 @@ class PropertiesController < ApplicationController
get '/:property/parents' do
prop = params[:property]
ont, submission = get_ontology_and_submission
p = ont.property(prop, submission)
p = ont.property(prop, submission, display_all_attributes: false)
error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil?

p.bring(:parents)
Expand All @@ -120,7 +120,7 @@ class PropertiesController < ApplicationController
get '/:property/children' do
prop = params[:property]
ont, submission = get_ontology_and_submission
p = ont.property(prop, submission)
p = ont.property(prop, submission, display_all_attributes: false)
error 404, "Property #{prop} not found in ontology #{ont.id.to_s}" if p.nil?

p.bring(:children)
Expand Down
21 changes: 15 additions & 6 deletions controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SearchController < ApplicationController
page_size: page_size,
sort: sort
})

total_found = page_data.aggregate
ontology_rank = LinkedData::Models::Ontology.rank
docs = {}
Expand Down Expand Up @@ -153,11 +153,17 @@ class SearchController < ApplicationController

fq = "agentType_t:#{type}" if type

qf = [
"acronymSuggestEdge^25 nameSuggestEdge^15 emailSuggestEdge^15 identifiersSuggestEdge^10 ", # start of the word first
"identifiers_texts^20 acronym_text^15 name_text^10 email_text^10 ", # full word match
"acronymSuggestNgram^2 nameSuggestNgram^1.5 email_text^1" # substring match last
].join(' ')
if params[:qf]
qf = params[:qf]
else
qf = [
"acronymSuggestEdge^25 nameSuggestEdge^15 emailSuggestEdge^15 identifiersSuggestEdge^10 ", # start of the word first
"identifiers_texts^20 acronym_text^15 name_text^10 email_text^10 ", # full word match
"acronymSuggestNgram^2 nameSuggestNgram^1.5 email_text^1" # substring match last
].join(' ')
end



if params[:sort]
sort = "#{params[:sort]} asc, score desc"
Expand Down Expand Up @@ -230,6 +236,9 @@ def process_search(params = nil)
doc[:submission] = submission
doc[:ontology_rank] = (ontology_rank[doc[:submissionAcronym]] && !ontology_rank[doc[:submissionAcronym]].empty?) ? ontology_rank[doc[:submissionAcronym]][:normalizedScore] : 0.0
doc[:properties] = MultiJson.load(doc.delete(:propertyRaw)) if include_param_contains?(:properties)

doc = filter_attrs_by_language(doc)

instance = doc[:provisional] ? LinkedData::Models::ProvisionalClass.read_only(doc) : LinkedData::Models::Class.read_only(doc)
docs.push(instance)
end
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
environment:
<<: *env
BUNDLE_APP_CONFIG: /srv/ontoportal/ontologies_api/.bundle

profiles:
- 4store
depends_on:
Expand All @@ -48,7 +49,7 @@ services:
- "9393:9393"
volumes:
# bundle volume for hosting gems installed by bundle; it speeds up gem install in local development
- app_api:/srv/ontoportal/ontologies_api
- .:/srv/ontoportal/ontologies_api
- repository:/srv/ontoportal/data/repository

ncbo_cron:
Expand Down
Loading

0 comments on commit 13bd205

Please sign in to comment.