Skip to content

Commit

Permalink
Merge pull request #64 from ontoportal-lirmm/development
Browse files Browse the repository at this point in the history
Merge to master: Release v2.3.1
  • Loading branch information
syphax-bouazzouni committed Dec 28, 2023
2 parents 165723b + 2cabca4 commit 286b56b
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ gem 'haml', '~> 5.2.2' # pin see https://github.com/ncbo/ontologies_api/pull/107
gem 'redcarpet'

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'goo', git: 'https://github.com/ontoportal-lirmm/goo.git', branch: 'master'
gem 'goo', git: 'https://github.com/ontoportal-lirmm/goo.git', branch: 'development'
gem 'ncbo_annotator', git: 'https://github.com/ontoportal-lirmm/ncbo_annotator.git', branch: 'master'
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 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'master'
gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'master'
gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development'

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
45 changes: 38 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/goo.git
revision: 03da25b671d2ffa515b5dce51c6bd35980ae60c7
branch: master
revision: 6187c205a1310c2f8a72fe8e07fcf99477060fa9
branch: development
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand All @@ -37,12 +37,13 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ncbo_cron.git
revision: 155db7a33794f03858893d2367cb119f27726a31
revision: f741e776379cf602d70bae1c0b4257bcbe3af99e
branch: master
specs:
ncbo_cron (0.0.1)
dante
goo
google-analytics-data
google-apis-analytics_v3
mlanett-redis-lock
multi_json
Expand All @@ -53,8 +54,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: e98b884999e5ce917a8be5fdc37f7b4797a1559e
branch: master
revision: d5af89ba5563cbd9bfc06c51a8330015dd737614
branch: development
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down Expand Up @@ -160,8 +161,22 @@ GEM
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.16.3)
gapic-common (0.21.1)
faraday (>= 1.9, < 3.a)
faraday-retry (>= 1.0, < 3.a)
google-protobuf (~> 3.18)
googleapis-common-protos (>= 1.4.0, < 2.a)
googleapis-common-protos-types (>= 1.11.0, < 2.a)
googleauth (~> 1.9)
grpc (~> 1.59)
get_process_mem (0.2.7)
ffi (~> 1.0)
google-analytics-data (0.4.0)
google-analytics-data-v1beta (>= 0.7, < 2.a)
google-cloud-core (~> 1.6)
google-analytics-data-v1beta (0.10.0)
gapic-common (>= 0.20.0, < 2.a)
google-cloud-errors (~> 1.0)
google-apis-analytics_v3 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
Expand All @@ -173,15 +188,29 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
google-cloud-core (1.6.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.1.0)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.3.1)
google-protobuf (3.25.1-x86_64-linux)
googleapis-common-protos (1.4.0)
google-protobuf (~> 3.14)
googleapis-common-protos-types (~> 1.2)
grpc (~> 1.27)
googleapis-common-protos-types (1.11.0)
google-protobuf (~> 3.18)
googleauth (1.9.1)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
grpc (1.60.0-x86_64-linux)
google-protobuf (~> 3.25)
googleapis-common-protos-types (~> 1.0)
haml (5.2.2)
temple (>= 0.8.0)
tilt
Expand Down Expand Up @@ -218,8 +247,9 @@ GEM
redis
multi_json (1.15.0)
multipart-post (2.3.0)
mutex_m (0.2.0)
net-http-persistent (2.9.4)
net-imap (0.4.8)
net-imap (0.4.9)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -323,7 +353,8 @@ GEM
rack-test
sinatra (~> 1.4.0)
tilt (>= 1.3, < 3)
sshkit (1.21.6)
sshkit (1.21.7)
mutex_m
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
systemu (2.6.5)
Expand Down
2 changes: 0 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
require 'oj'
require 'multi_json'
require 'cgi'
require 'google/apis/analytics_v3'
require 'google/api_client/auth/key_utils'

# NCBO dependencies
require 'ontologies_linked_data'
Expand Down
45 changes: 45 additions & 0 deletions controllers/analytics_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'csv'

class AnalyticsController < ApplicationController

##
# get all ontology analytics for a given year/month combination
# TODO use a namespace analytics after migration the old OntologyAnalyticsController
namespace "/data/analytics" do

get '/ontologies' do
expires 86400, :public
year = year_param(params)
error 400, "The year you supplied is invalid. Valid years start with 2 and contain 4 digits." if params["year"] && !year
month = month_param(params)
error 400, "The month you supplied is invalid. Valid months are 1-12." if params["month"] && !month
acronyms = restricted_ontologies_to_acronyms(params)
analytics = Ontology.analytics(year, month, acronyms)

reply analytics
end


get '/users' do
expires 86400, :public
year = year_param(params)
error 400, "The year you supplied is invalid. Valid years start with 2 and contain 4 digits." if params["year"] && !year
month = month_param(params)
error 400, "The month you supplied is invalid. Valid months are 1-12." if params["month"] && !month
analytics = User.analytics(year, month)
reply analytics['all_users']
end

get '/page_visits' do
expires 86400, :public
year = year_param(params)
error 400, "The year you supplied is invalid. Valid years start with 2 and contain 4 digits." if params["year"] && !year
month = month_param(params)
error 400, "The month you supplied is invalid. Valid months are 1-12." if params["month"] && !month
analytics = User.page_visits_analytics
reply analytics['all_pages']
end

end

end
4 changes: 2 additions & 2 deletions helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def month_param(params=nil)
if params["month"]
month = params["month"].strip
if %r{(?<month>^(0[1-9]|[1-9]|1[0-2])$)}x === month
month.to_i
month.to_i.to_s
end
end
end
Expand All @@ -287,7 +287,7 @@ def year_param(params=nil)
if params["year"]
year = params["year"].strip
if %r{(?<year>^([1-2]\d{3})$)}x === year
year.to_i
year.to_i.to_s
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion test/controllers/test_ontology_analytics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ def self.before_suite
puts " This test cannot be run because there #{db_size} redis entries (max #{MAX_TEST_REDIS_SIZE}). You are probably pointing to the wrong redis backend. "
return
end
@@redis.set(LinkedData::Models::Ontology::ONTOLOGY_ANALYTICS_REDIS_FIELD, Marshal.dump(ANALYTICS_DATA))

stringy_keys = ANALYTICS_DATA.transform_values{|year| year.map{|k,v| [k.to_s , v.stringify_keys]}.to_h}
@@redis.set(LinkedData::Models::Ontology::ONTOLOGY_ANALYTICS_REDIS_FIELD, Marshal.dump(stringy_keys))
@@onts = {
"NCIT" => "NCIT Ontology",
"ONTOMA" => "ONTOMA Ontology",
Expand Down

0 comments on commit 286b56b

Please sign in to comment.