Class: Admin::StatsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/happy_seed/admin/templates/app/controllers/admin/stats_controller.rb

Instance Method Summary collapse

Instance Method Details

#statsObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/generators/happy_seed/admin/templates/app/controllers/admin/stats_controller.rb', line 4

def stats
  if params[:scope].blank?
    render :json => { :errors => "scope not set" }, :status => 422
  else
    cls = User
    cls = Identity.where( "provider = ?", "twitter" ) if params[:scope] == 'twitter_users'
    cls = Identity.where( "provider = ?", "instagram" ) if params[:scope] == 'instagram_users'
    ret = cls.group_by_month
    render json: ret
  end
end