Class: StatisticsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- StatisticsController
- Defined in:
- app/controllers/statistics_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
#advertise, #cache_action?, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
Methods included from BaseHelper
#add_friend_link, #ajax_spinner_for, #avatar_for, #block_to_partial, #box, #city_cloud, #clippings_link, #commentable_url, #container_title, #excerpt_with_jump, #flash_class, #forum_page?, #is_current_user_and_featured?, #jumbotron, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #render_jumbotron, #render_widgets, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #tag_auto_complete_field, #time_ago_in_words, #time_ago_in_words_or_date, #tiny_mce_init_if_needed, #tiny_mce_js, #topnav_tab, #truncate_words, #truncate_words_with_highlight, #widget
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
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/statistics_controller.rb', line 5 def index @total_users = User.where('activated_at IS NOT NULL').count @unactivated_users = User.where('activated_at IS NULL').count @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) # Query returns a hash of user_id to number of activities for that user. @active_users_count = Activity.group("user_id").having("count(created_at > ?) > 0", 1.month.ago).count.keys.size @active_users = User.find_by_activity({:since => 1.month.ago}) @percent_reporting_zip = (User.where("zip IS NOT NULL").count / @total_users.to_f)*100 users_reporting_gender = User.where("gender IS NOT NULL").count @percent_male = (User.where('gender = ?', User::MALE).count / users_reporting_gender.to_f) * 100 @percent_female = (User.where('gender = ?', User::FEMALE).count / users_reporting_gender.to_f) * 100 @featured_writers = User.find_featured @posts = Post.includes(:user).where('? <= posts.published_at AND posts.published_at <= ? AND users.featured_writer = ?', Time.now.beginning_of_month, (Time.now.end_of_month + 1.day), true).includes(:users) end |