Skip to content
Snippets Groups Projects
Commit 949d46b8 authored by bfs15's avatar bfs15
Browse files

Merge branch 'rspec' of gitlab.c3sl.ufpr.br:portalmec/portalmec into rspec

parents f4617a78 c4f2eaef
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
......@@ -7,9 +7,10 @@ RSpec.shared_context "authenticate_user", shared_context: :metadata do
let(:auth_client) { @auth_headers['client'] }
let(:uid) { @auth_headers['uid'] }
let(:access_token) { @auth_headers['access-token'] }
let(:role) { Role.all }
before do
@user = create(:user)
@user = create(:user, roles: [role.find_by(name: 'teacher')])
@auth_headers = @user.create_new_auth_token
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