Skip to content

Commit

Permalink
Merge branch 'feature/add-diff-parsing-endpoint' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilelkihal authored and syphax-bouazzouni committed Sep 18, 2024
2 parents da2ef79 + 5d56ebb commit f1a61a9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.6 # Not needed with a .ruby-version file
ruby-version: 2.7.8 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: get-deployment-config
uses: actions/checkout@v3
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ gem 'json-ld'
gem 'google-apis-core', '0.15.0'
gem 'google-protobuf', '3.25.3'


# Rack middleware
gem 'ffi'
gem 'rack-accept', '~> 0.4'
Expand Down Expand Up @@ -53,7 +52,7 @@ gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branc
gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master'
gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development'
gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development'
gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development'
gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'feature/parse-diff-files'

group :development do
# bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42
Expand Down
30 changes: 15 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 9605eb44c4271c60bedda0520e85d8c3fa2513ac
branch: development
revision: 99b934317f303f9ea839413de4ff8a5638ac074f
branch: feature/parse-diff-files
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down Expand Up @@ -108,7 +108,7 @@ GEM
multi_json (~> 1.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
airbrussh (1.5.2)
airbrussh (1.5.3)
sshkit (>= 1.6.1, != 1.7.0)
backports (3.25.0)
base64 (0.2.0)
Expand Down Expand Up @@ -178,7 +178,7 @@ GEM
google-analytics-data (0.6.1)
google-analytics-data-v1beta (>= 0.11, < 2.a)
google-cloud-core (~> 1.6)
google-analytics-data-v1beta (0.13.0)
google-analytics-data-v1beta (0.13.1)
gapic-common (>= 0.21.1, < 2.a)
google-cloud-errors (~> 1.0)
google-apis-analytics_v3 (0.16.0)
Expand All @@ -202,7 +202,7 @@ GEM
google-protobuf (>= 3.18, < 5.a)
googleapis-common-protos-types (~> 1.7)
grpc (~> 1.41)
googleapis-common-protos-types (1.15.0)
googleapis-common-protos-types (1.16.0)
google-protobuf (>= 3.18, < 5.a)
googleauth (1.11.0)
faraday (>= 1.0, < 3.a)
Expand Down Expand Up @@ -231,12 +231,12 @@ GEM
rdf (>= 2.2.8, < 4.0)
json-schema (2.8.1)
addressable (>= 2.4)
jwt (2.8.2)
jwt (2.9.0)
base64
kgio (2.11.4)
libxml-ruby (5.0.3)
link_header (0.0.8)
logger (1.6.0)
logger (1.6.1)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.1)
Expand All @@ -247,17 +247,17 @@ GEM
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0820)
mime-types-data (3.2024.0903)
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)
net-http-persistent (4.0.2)
net-http-persistent (4.0.4)
connection_pool (~> 2.2)
net-imap (0.4.14)
net-imap (0.4.16)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -277,6 +277,7 @@ GEM
omni_logger (0.1.4)
logger
os (1.1.4)
ostruct (0.6.0)
parallel (1.26.3)
parseconfig (1.1.2)
pony (1.13.1)
Expand Down Expand Up @@ -340,8 +341,7 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.3.6)
strscan
rexml (3.3.7)
rsolr (2.6.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
Expand All @@ -362,7 +362,7 @@ GEM
simplecov-cobertura (2.1.0)
rexml
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
sinatra (1.4.8)
rack (~> 1.5)
Expand All @@ -377,12 +377,12 @@ GEM
rack-test
sinatra (~> 1.4.0)
tilt (>= 1.3, < 3)
sshkit (1.23.0)
sshkit (1.23.1)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
net-ssh (>= 2.8.0)
strscan (3.1.0)
ostruct
systemu (2.6.5)
temple (0.10.3)
tilt (2.4.0)
Expand Down
19 changes: 19 additions & 0 deletions controllers/ontology_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,25 @@ class OntologySubmissionsController < ApplicationController
end
end

get '/:ontology_submission_id/diff' do
acronym = params["acronym"]
submission_attributes = [:submissionId, :submissionStatus, :diffFilePath]
ont = Ontology.find(acronym).include(:submissions => submission_attributes).first
error 422, "You must provide an existing `acronym` to download" if ont.nil?
ont.bring(:viewingRestriction)
check_access(ont)
ont_restrict_downloads = LinkedData::OntologiesAPI.settings.restrict_download
error 403, "License restrictions on download for #{acronym}" if ont_restrict_downloads.include? acronym
submission = ont.submission(params['ontology_submission_id'].to_i)
error 404, "There is no such submission for download" if submission.nil?
file_path = submission.diffFilePath
if File.readable? file_path
reply submission.parse_diff_report
else
error 500, "Cannot read submission diff file: #{file_path}"
end
end

##
# Download a submission diff file
get '/:ontology_submission_id/download_diff' do
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/test_ontology_submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,16 @@ def test_submissions_param_include
test_submissions_custom_includes
end

def test_submission_diff
num_onts_created, created_ont_acronyms, onts = create_ontologies_and_submissions(ont_count: 1, submission_count: 2,
process_submission: true,
process_options: { process_rdf: true, extract_metadata: false, diff: true} )

ont = onts.first
sub = ont.latest_submission(status: :any)

get "/ontologies/#{ont.acronym}/submissions/#{sub.submissionId}/diff"
end
private
def submission_keys(sub)
sub.to_hash.keys - %w[@id @type id]
Expand Down

0 comments on commit f1a61a9

Please sign in to comment.