forked from ontoportal/ontologies_api
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into stage
- Loading branch information
Showing
2 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'csv' | ||
|
||
class OntologyAnalyticsController < 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters