Commit b8ca31b6 authored by chfernandez's avatar chfernandez

improved weekly_user_stats in admin with a dropdown box by week to list all...

improved weekly_user_stats in admin with a dropdown box by week to list all new users of that week also a link_to the user profile so the admin can sent welcome msgs, etc
parent 854735dc
......@@ -22,16 +22,19 @@ class AdminsController < ApplicationController
end
def weekly_user_stats
@created_users_by_day = User.where("username IS NOT NULL").count(:group => "date(created_at)")
@created_users_by_week = {}
@created_users_by_day.keys.each do |k|
unless k.nil?
if @created_users_by_week[k.beginning_of_week].blank?
@created_users_by_week[k.beginning_of_week] = @created_users_by_day[k]
else
@created_users_by_week[k.beginning_of_week] += @created_users_by_day[k]
@created_users = User.where("username IS NOT NULL")
@created_users_by_week = Hash.new{ |h,k| h[k] = [] }
@created_users.each do |u|
unless u.nil?
@created_users_by_week[u.created_at.beginning_of_week.strftime("%Y-%m-%d")].push("#{u.username}")
end
end
unless(params[:week]).nil?
# @segment = "#{@created_users_by_week[(params[:week])]}"
@counter = "#{@created_users_by_week[(params[:week])].count}"
else
@segment = "date not found"
end
end
......
......@@ -6,8 +6,15 @@
.span-24.last
%h2
= "Users per week (Current server date is: #{Time.now.to_date}) "
%ul
- @created_users_by_week.keys.sort.reverse.each do |k|
%li
= "Week starting on #{k} , #{@created_users_by_week[k]}"
= "Current server date is: #{Time.now.to_date}) "
= form_tag('/admins/weekly_user_stats', :method => 'get') do
= select_tag(:week, options_for_select(@created_users_by_week.keys))
= submit_tag 'go'
amount of new users this week:
= @counter
%br
- @created_users_by_week[(params[:week])].each do |m|
= link_to m, "/u/#{m}"
%br
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment