Class: Users::RegistrationServices
- Inherits:
-
Lesli::ApplicationLesliService
- Object
- Lesli::ApplicationLesliService
- Users::RegistrationServices
- Defined in:
- app/services/lesli_audit/users/registration_services.rb
Instance Method Summary collapse
-
#index ⇒ Hash
Paginated list of the records.
Instance Method Details
#index ⇒ Hash
Returns Paginated list of the records.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/services/lesli_audit/users/registration_services.rb', line 41 def index period = 'month' #Get filters from http request group = query[:group] #Get period only if the request have filters unless group.blank? period = group end unless period.blank? || (period != 'day' && period != 'week' && period != 'month' && period != 'year') registrations = current_user.account.users.group("DATE_TRUNC('#{period}', created_at)") registrations.order("date_trunc_#{period}_created_at DESC").count.map do |request| { :date => Date2.new(request[0]).date.to_s, :count => request[1] } end end end |