Skip to content
Snippets Groups Projects
Commit a6a02074 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Merge branch 'download_statistics' into 'master'

Added download by month query to statistics controller

See merge request !387
parents da55200a 4d2accab
No related branches found
No related tags found
No related merge requests found
class V1::StatisticsController < ApplicationController
# GET v1/statistics
# GET v1/statistics.json
def index
statistics = {:count => count_learning_objects, :month_publications => month_publications, :month_downloads => month_downloads}
statistics = { count: count_learning_objects, month_publications: month_publications, month_downloads: month_downloads }
render json: statistics
end
private
def count_learning_objects
LearningObject.where('state = ?', LearningObject.states[:published]).count
end
def month_publications
LearningObject.where('extract (month from published_at) = ? and extract (year from published_at) = ?', Time.now.month, Time.now.year).count
end
def count_learning_objects
LearningObject.where('state = ?', LearningObject.states[:published]).count
end
def month_downloads
end
def month_publications
LearningObject.where('extract (month from published_at) = ? and extract (year from published_at) = ?', Time.current.month, Time.current.year).count
end
def month_downloads
Download.where('extract (month from created_at) = ? and extract (year from created_at) = ?', Time.current.month, Time.current.year).count
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment