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

View File

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