Class: StatisticsController

Inherits:
BaseController show all
Defined in:
app/controllers/statistics_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index

Methods included from LocalizedApplication

#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale

Methods included from AuthenticatedSystem

#login_by_token, #update_last_seen_at

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/statistics_controller.rb', line 5

def index
  @total_users = User.count(:conditions => ['activated_at IS NOT NULL'])
  @unactivated_users = User.count(:conditions => ['activated_at IS NULL'])

  @yesterday_new_users = find_new_users(1.day.ago.midnight, Date.today.midnight)
  @today_new_users = find_new_users(Date.today.midnight, Date.today.tomorrow.midnight)  

  @active_users_count = Activity.count(:all, :group => "user_id", :conditions => ["created_at > ?", 1.month.ago]).size

  @active_users = User.find_by_activity({:since => 1.month.ago})
  
  @percent_reporting_zip = (User.count(:all, :conditions => "zip IS NOT NULL") / @total_users.to_f)*100
  
  users_reporting_gender = User.count(:all, :conditions => "gender IS NOT NULL")
  @percent_male = (User.count(:all, :conditions => ['gender = ?', User::MALE ]) / users_reporting_gender.to_f) * 100
  @percent_female = (User.count(:all, :conditions => ['gender = ?', User::FEMALE] ) / users_reporting_gender.to_f) * 100        
  
  @featured_writers = User.find_featured

  @posts = Post.find(:all, :conditions => ['? <= posts.published_at AND posts.published_at <= ? AND users.featured_writer = ?', Time.now.beginning_of_month, (Time.now.end_of_month + 1.day), true], :include => :user)        
end