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: Create graphs endpoints #115

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.6
2.7.5
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ gem 'redcarpet'

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'ncbo_annotator', git: 'https://github.com/ontoportal-lirmm/ncbo_annotator.git', branch: 'development'
gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branch: 'master'
gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master'
gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branch: 'development'
gem 'ncbo_ontology_recommender', git: 'https://github.com/ontoportal-lirmm/ncbo_ontology_recommender.git', branch: 'development'
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'
Expand Down
100 changes: 51 additions & 49 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
GIT
remote: https://github.com/ncbo/ncbo_ontology_recommender.git
revision: 9dbd4f179e42c52095129d353a5ac584e9bd47f3
branch: master
specs:
ncbo_ontology_recommender (0.0.1)
goo
ncbo_annotator
ontologies_linked_data
redis

GIT
remote: https://github.com/ontoportal-lirmm/goo.git
revision: f8ac7b00e8d8b46d1eea04de014175525c1cdd83
Expand Down Expand Up @@ -40,8 +29,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ncbo_cron.git
revision: bed0ff08408ad1241db3513992ad025a253eeef0
branch: master
revision: 70de4d7a3f625e41b263015fdd11f54adea0545d
branch: development
specs:
ncbo_cron (0.0.1)
dante
Expand All @@ -55,9 +44,20 @@ GIT
redis
rufus-scheduler (~> 2.0.24)

GIT
remote: https://github.com/ontoportal-lirmm/ncbo_ontology_recommender.git
revision: a0e36c89e6e2f8502cac288df2992625649dad7a
branch: development
specs:
ncbo_ontology_recommender (0.0.1)
goo
ncbo_annotator
ontologies_linked_data
redis

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 312ef426eeaa461e88fa23124ea5fd531f4276ba
revision: d84e379b6ce6cd0e8c4672e5056279b3cc643827
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand Down Expand Up @@ -117,9 +117,9 @@ GEM
base64 (0.2.0)
bcrypt (3.1.20)
bcrypt_pbkdf (1.1.1)
bigdecimal (3.1.8)
bigdecimal (3.1.9)
builder (3.3.0)
capistrano (3.19.1)
capistrano (3.19.2)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
Expand All @@ -133,12 +133,12 @@ GEM
sshkit (~> 1.3)
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
connection_pool (2.5.0)
crack (0.4.5)
rexml
cube-ruby (0.0.3)
dante (0.2.0)
date (3.3.4)
date (3.4.1)
declarative (0.0.20)
docile (1.4.1)
domain_name (0.6.20240107)
Expand All @@ -164,7 +164,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.1)
google-analytics-data-v1beta (0.14.0)
gapic-common (>= 0.21.1, < 2.a)
google-cloud-errors (~> 1.0)
google-apis-analytics_v3 (0.16.0)
Expand All @@ -188,7 +188,7 @@ GEM
google-protobuf (>= 3.18, < 5.a)
googleapis-common-protos-types (~> 1.7)
grpc (~> 1.41)
googleapis-common-protos-types (1.16.0)
googleapis-common-protos-types (1.17.0)
google-protobuf (>= 3.18, < 5.a)
googleauth (1.11.2)
faraday (>= 1.0, < 3.a)
Expand All @@ -203,27 +203,27 @@ GEM
haml (5.2.2)
temple (>= 0.8.0)
tilt
hashdiff (1.1.1)
hashdiff (1.1.2)
htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.7)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.5)
json (2.9.1)
json-ld (3.0.2)
multi_json (~> 1.12)
rdf (>= 2.2.8, < 4.0)
json-schema (2.8.1)
addressable (>= 2.4)
jwt (2.9.3)
jwt (2.10.1)
base64
kgio (2.11.4)
language_server-protocol (3.17.0.3)
libxml-ruby (5.0.3)
link_header (0.0.8)
logger (1.6.1)
logger (1.6.5)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.1)
Expand All @@ -235,19 +235,19 @@ GEM
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2024.1001)
mime-types-data (3.2025.0107)
mini_mime (1.1.5)
minitest (5.25.1)
minitest (5.25.4)
minitest-hooks (1.5.2)
minitest (> 5.3)
minitest-stub_any_instance (1.0.3)
mlanett-redis-lock (0.2.7)
redis
multi_json (1.15.0)
mutex_m (0.2.0)
net-http-persistent (4.0.4)
mutex_m (0.3.0)
net-http-persistent (4.0.5)
connection_pool (~> 2.2)
net-imap (0.4.17)
net-imap (0.4.18)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -262,22 +262,22 @@ GEM
net-protocol
net-ssh (7.3.0)
netrc (0.11.0)
newrelic_rpm (9.14.0)
oj (3.16.6)
newrelic_rpm (9.16.1)
oj (3.16.9)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
omni_logger (0.1.4)
logger
os (1.1.4)
ostruct (0.6.0)
ostruct (0.6.1)
parallel (1.26.3)
parseconfig (1.1.2)
parser (3.3.5.0)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
pony (1.13.1)
mail (>= 2.0)
pry (0.14.2)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.1.1)
Expand All @@ -295,7 +295,7 @@ GEM
rack (>= 1.2.0)
rack-protection (1.5.5)
rack
rack-test (2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rack-timeout (0.7.0)
rainbow (3.1.1)
Expand All @@ -319,14 +319,14 @@ GEM
redcarpet (3.6.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
redis-client (0.23.1)
connection_pool
redis-rack-cache (2.2.1)
rack-cache (>= 1.10, < 2)
redis-store (>= 1.6, < 2)
redis-store (1.11.0)
redis (>= 4, < 6)
regexp_parser (2.9.2)
regexp_parser (2.10.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand All @@ -339,26 +339,26 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.3.9)
rexml (3.4.0)
rsolr (2.6.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
rubocop (1.67.0)
rubocop (1.70.0)
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 (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.33.0)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby-xxHash (0.4.0.2)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
rubyzip (2.4.1)
rufus-scheduler (2.0.24)
tzinfo (>= 0.3.22)
signet (0.19.0)
Expand Down Expand Up @@ -397,13 +397,15 @@ GEM
systemu (2.6.5)
temple (0.10.3)
thread_safe (0.3.6)
tilt (2.4.0)
timeout (0.4.1)
tilt (2.6.0)
timeout (0.4.3)
trailblazer-option (0.1.2)
tzinfo (1.2.11)
thread_safe (~> 0.1)
uber (0.1.0)
unicode-display_width (2.6.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
unicorn (6.1.0)
kgio (~> 2.6)
raindrops (~> 0.7)
Expand All @@ -416,7 +418,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.2)
webrick (1.9.1)

PLATFORMS
x86_64-linux
Expand Down
29 changes: 29 additions & 0 deletions controllers/admin_graphs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'ncbo_cron/graphs_counts'
class AdminGraphsController < ApplicationController

namespace '/admin' do
GRAPH_COUNT_REPORT_PATH = NcboCron.settings.graphs_counts_report_path
before do
if LinkedData.settings.enable_security && (!env['REMOTE_USER'] || !env['REMOTE_USER'].admin?)
error 403, 'Access denied'
end
end

get '/graphs' do
output = NcboCron::GraphsCounts.new(nil, GRAPH_COUNT_REPORT_PATH).read_graph_counts
reply output
end

post '/graphs' do
NcboCron::GraphsCounts.new(nil, GRAPH_COUNT_REPORT_PATH).run
reply({ message: 'Graph counts generated', status: 200 })
end

delete '/graphs' do
url = params['url']
error 400, 'You must provide a valid URL for the graph to delete' if url.blank?
Goo.sparql_data_client.delete_graph(url)
reply({ message: "Graph #{url} deleted", status: 200 })
end
end
end
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
- "9393:9393"
volumes:
# bundle volume for hosting gems installed by bundle; it speeds up gem install in local development
- .:/srv/ontoportal/ontologies_api
- app_api:/srv/ontoportal/ontologies_api
- repository:/srv/ontoportal/data/repository

ncbo_cron:
Expand Down Expand Up @@ -199,4 +199,3 @@ volumes:
mgrep:
logs:
history:

2 changes: 2 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
ruby = "2.7.8"
Loading