This commit is contained in:
Manson Wang 2014-03-27 12:10:02 +08:00
parent 2d34d9edcf
commit 032a14e5a2
2 changed files with 44 additions and 43 deletions

31
Gemfile
View File

@ -1,7 +1,7 @@
source 'http://rubygems.org'
gem 'rails', "~> 3.2.16"
gem "brakeman"
# gem "brakeman"
gem 'mime-types'
gem 'bson_ext'
@ -9,16 +9,16 @@ gem 'carrierwave'
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
gem "net-ldap", "~> 0.3.1"
gem 'devise', '2.0'
gem 'exception_notification' # Send error trace
# gem 'exception_notification' # Send error trace
gem 'execjs'
gem 'jquery-rails', '3.0.4'
gem 'jquery-ui-rails', "4.0.5"
gem "select2-rails", '3.3.1'
gem 'kaminari'
gem 'time_difference'
gem "acts_as_unvlogable"
gem 'youtube_it'
gem 'gotcha'
# gem 'time_difference'
# gem "acts_as_unvlogable"
# gem 'youtube_it'
# gem 'gotcha'
gem "geocoder"
gem 'httparty'
#database
@ -27,7 +27,7 @@ gem 'mongoid', '> 2.1', '< 3.0.0'
gem 'mongoid-tree', :require => 'mongoid/tree'
gem "mongo_session_store-rails3", '3.0.6'
gem 'nokogiri'
gem 'tire'
# gem 'tire'
#built in modules
eval(File.read(File.dirname(__FILE__) + '/built_in_extensions.rb'))
@ -37,19 +37,19 @@ eval(File.read(File.dirname(__FILE__) + '/downloaded_extensions.rb'))
#form helpers
gem 'dynamic_form', :git => 'git@gitlab.tp.rulingcom.com:saurabh/dynamic-form.git'
gem 'fb_graph'
# gem 'fb_graph'
gem 'rack-gridfs'
gem 'radius'
# gem 'radius'
gem 'rake'
# gem 'remotipart'
gem 'resque', :require => 'resque/server' # background jobs
gem 'resque-scheduler' # job scheduling
gem 'resque-restriction'
# gem 'resque-restriction'
#gem 'rb-readline'
# gem 'ruby-debug19'
gem 'rubyzip', '< 1.0.0'
gem 'progress_bar'
# gem 'progress_bar'
gem 'sinatra'
#gem 'sinatra-contrib'
@ -61,7 +61,7 @@ gem 'ckeditor'
gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
gem 'libv8', '~> 3.11.8' if RUBY_PLATFORM.downcase.include?("linux")
gem 'mongoid-encryptor', :require => 'mongoid/encryptor'
gem 'rb-readline','~> 0.4.2' if RUBY_PLATFORM.downcase.include?("linux")
# gem 'rb-readline','~> 0.4.2' if RUBY_PLATFORM.downcase.include?("linux")
gem "impressionist",'1.2.0'
@ -71,21 +71,22 @@ gem "impressionist",'1.2.0'
gem 'redis','>= 2.1.1'
# gem 'chinese_pinyin', '0.4.1'
# add rmmseg if you need search by segment words
gem 'rmmseg-cpp-huacnlee', '0.2.9'
# gem 'rmmseg-cpp-huacnlee', '0.2.9'
gem 'redis-namespace'
# gem 'redis-search'
gem 'syslog-logger'
gem "recaptcha", :require => "recaptcha/rails"
# gem "recaptcha", :require => "recaptcha/rails"
gem "chartkick"
gem 'usagewatch'
gem 'unicorn'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
# gem 'uglifier'
end

View File

@ -1,36 +1,36 @@
class DashboardCounter < Resque::Plugins::RestrictionJob
@queue = :high
# class DashboardCounter < Resque::Plugins::RestrictionJob
# @queue = :high
def self.perform(*args)
site = Site.first
obj = new(*args)
site.dashboard_counter[:visitors_this_week] = obj.display_visitors_this_week
site.dashboard_counter[:visitors_this_month] = obj.display_visitors_this_month
site.dashboard_counter[:visitors_this_year] = obj.display_visitors_this_year
site.save
OrbitLogger.info "DashboardCounter done #{site.dashboard_counter.to_s}"
end
# def self.perform(*args)
# site = Site.first
# obj = new(*args)
# site.dashboard_counter[:visitors_this_week] = obj.display_visitors_this_week
# site.dashboard_counter[:visitors_this_month] = obj.display_visitors_this_month
# site.dashboard_counter[:visitors_this_year] = obj.display_visitors_this_year
# site.save
# OrbitLogger.info "DashboardCounter done #{site.dashboard_counter.to_s}"
# end
def display_visitors(options={})
impressions = Impression.where(options).and(:referrer.ne => nil)
impressions.map{|i| i[:session_hash]}.uniq.count
end
# def display_visitors(options={})
# impressions = Impression.where(options).and(:referrer.ne => nil)
# impressions.map{|i| i[:session_hash]}.uniq.count
# end
def display_visitors_today
display_visitors(created_at: {'$gte' => Date.today.beginning_of_day, '$lte' => Date.today.end_of_day})
end
# def display_visitors_today
# display_visitors(created_at: {'$gte' => Date.today.beginning_of_day, '$lte' => Date.today.end_of_day})
# end
def display_visitors_this_week
display_visitors(created_at: {'$gte' => Date.today.beginning_of_week, '$lte' => Date.today.end_of_week})
end
# def display_visitors_this_week
# display_visitors(created_at: {'$gte' => Date.today.beginning_of_week, '$lte' => Date.today.end_of_week})
# end
def display_visitors_this_month
display_visitors(created_at: {'$gte' => Date.today.beginning_of_month, '$lte' => Date.today.end_of_month})
end
# def display_visitors_this_month
# display_visitors(created_at: {'$gte' => Date.today.beginning_of_month, '$lte' => Date.today.end_of_month})
# end
def display_visitors_this_year
display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year})
end
# def display_visitors_this_year
# display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year})
# end
end
# end