Skip to content

Commit

Permalink
Feature: Add submission metrics to the indexed data
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Apr 3, 2024
1 parent 946b4bf commit 026c9c4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
22 changes: 11 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/ontoportal-lirmm/goo.git
revision: 8ddd2d719617ad082c6964a9efdac153cdd2b48e
branch: master
revision: 0e554fce49713ce4d5a742a06c2fb59a547caf47
branch: development
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -41,7 +41,7 @@ GEM
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
bigdecimal (3.1.6)
bigdecimal (3.1.7)
builder (3.2.4)
coderay (1.1.3)
concurrent-ruby (1.2.3)
Expand Down Expand Up @@ -114,7 +114,7 @@ GEM
method_source (1.0.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0206)
mime-types-data (3.2024.0305)
mini_mime (1.1.5)
minitest (4.7.5)
minitest-reporters (0.14.24)
Expand All @@ -132,7 +132,7 @@ GEM
net-protocol
net-protocol (0.2.2)
timeout
net-smtp (0.4.0.1)
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
oj (2.18.5)
Expand All @@ -149,7 +149,7 @@ GEM
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.4)
public_suffix (5.0.5)
racc (1.7.3)
rack (1.6.13)
rack-test (0.8.3)
Expand All @@ -173,7 +173,7 @@ GEM
rexml (~> 3.2)
redis (5.1.0)
redis-client (>= 0.17.0)
redis-client (0.20.0)
redis-client (0.21.1)
connection_pool
regexp_parser (2.9.0)
request_store (1.6.0)
Expand All @@ -186,18 +186,18 @@ GEM
rexml (3.2.6)
rsolr (1.1.2)
builder (>= 2.1.2)
rubocop (1.61.0)
rubocop (1.62.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.1)
rubocop-ast (1.31.2)
parser (>= 3.3.0.4)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
Expand All @@ -224,7 +224,7 @@ GEM
unicode-display_width (2.5.0)
uuid (2.3.9)
macaddr (~> 1.0)
webmock (3.20.0)
webmock (3.23.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.included(base)
end

def index_sorted_ids(ids, ontology, conn, logger, commit = true)
total_triples = Parallel.map(ids.each_slice(100), in_threads: 10) do |ids_slice|
total_triples = Parallel.map(ids.each_slice(1000), in_threads: 10) do |ids_slice|
index_ids = 0
triples_count = 0
documents = {}
Expand All @@ -48,7 +48,7 @@ def index_sorted_ids(ids, ontology, conn, logger, commit = true)

def index_all_data(logger, commit = true)
page = 1
size = 1000
size = 10_000
count_ids = 0
total_time = 0
total_triples = 0
Expand Down
5 changes: 4 additions & 1 deletion lib/ontologies_linked_data/models/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ class Contact < LinkedData::Models::Base
embedded true

def embedded_doc
"#{self.name} #{self.email}"
bring(:name) if bring?(:name)
bring(:email) if bring?(:email)

"#{self.name} | #{self.email}"
end

end
Expand Down
8 changes: 8 additions & 0 deletions lib/ontologies_linked_data/models/metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def self.metrics_id_generator(m)
raise ArgumentError, "Metrics id needs to be set"
#return RDF::URI.new(m.submission.id.to_s + "/metrics")
end

def embedded_doc
doc = indexable_object
doc.delete(:resource_model)
doc.delete(:resource_id)
doc.delete(:id)
doc
end
end
end
end
20 changes: 17 additions & 3 deletions test/models/test_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def setup

def test_search_ontology
ont_count, ont_acronyms, created_ontologies = create_ontologies_and_submissions({
process_submission: false,
process_submission: true,
process_options: {process_rdf: true, extract_metadata: false, run_metrics: true},
acronym: 'BROTEST',
name: 'ontTEST Bla',
file_path: '../../../../test/data/ontology_files/BRO_v3.2.owl',
Expand All @@ -23,6 +24,7 @@ def test_search_ontology
})

ontologies = LinkedData::Models::Ontology.search('*:*', { fq: 'resource_model: "ontology"' })['response']['docs']

assert_equal 3, ontologies.size
ontologies.each do |ont|
select_ont = created_ontologies.select { |ont_created| ont_created.id.to_s.eql?(ont['id']) }.first
Expand All @@ -36,7 +38,6 @@ def test_search_ontology

submissions = LinkedData::Models::Ontology.search('*:*', { fq: 'resource_model: "ontology_submission"' })['response']['docs']
assert_equal 9, submissions.size

submissions.each do |sub|
created_sub = LinkedData::Models::OntologySubmission.find(RDF::URI.new(sub['id'])).first&.bring_remaining
refute_nil created_sub
Expand All @@ -55,7 +56,20 @@ def test_search_ontology
assert_equal sub['openSearchDescription_t'], created_sub.openSearchDescription
assert_equal sub['endpoint_txt'], created_sub.endpoint
assert_equal sub['uploadFilePath_t'], created_sub.uploadFilePath
assert_equal sub['submissionStatus_txt'], created_sub.submissionStatus.map(&:id)
assert_equal sub['submissionStatus_txt'].sort, created_sub.submissionStatus.map{|x| x.id.to_s}.sort

created_sub.metrics.bring_remaining

assert_equal sub['metrics_classes_i'], created_sub.metrics.classes
assert_equal sub['metrics_individuals_i'], created_sub.metrics.individuals
assert_equal sub['metrics_properties_i'], created_sub.metrics.properties
assert_equal sub['metrics_maxDepth_i'], created_sub.metrics.maxDepth
assert_equal sub['metrics_maxChildCount_i'], created_sub.metrics.maxChildCount
assert_equal sub['metrics_averageChildCount_i'], created_sub.metrics.averageChildCount
assert_equal sub['metrics_classesWithOneChild_i'], created_sub.metrics.classesWithOneChild
assert_equal sub['metrics_classesWithMoreThan25Children_i'], created_sub.metrics.classesWithMoreThan25Children
assert_equal sub['metrics_classesWithNoDefinition_i'], created_sub.metrics.classesWithNoDefinition

embed_doc = created_sub.ontology.bring_remaining.embedded_doc
embed_doc.each do |k, v|
if v.is_a?(Array)
Expand Down

0 comments on commit 026c9c4

Please sign in to comment.