fix counter for recording request.
This commit is contained in:
parent
8f393e1079
commit
27b86b078a
|
@ -9,8 +9,7 @@ module ApplicationHelper
|
|||
|
||||
def delayed_impressionist(item)
|
||||
user_id = current_user.nil? ? nil : current_user.id
|
||||
request = DelayImpressionistRequest.new(request)
|
||||
Resque.enqueue(DelayedImpressionist,:request=>request,:obj=>item,:class=>item.class.to_s,:controller_name=>controller_name,:action_name=>action_name,:user=>user_id)
|
||||
Resque.enqueue(DelayedImpressionist,:request=>DelayImpressionistRequest.new(request),:obj=>item,:class=>item.class.to_s,:controller_name=>controller_name,:action_name=>action_name,:user=>user_id)
|
||||
end
|
||||
|
||||
def check_user_role_enable(attribute_fields)
|
||||
|
|
|
@ -17,10 +17,16 @@ class DelayedImpressionist
|
|||
arg = args[0]
|
||||
@request= DelayImpressionistRequest.new
|
||||
@request.restore(arg["request"])
|
||||
request = @request
|
||||
obj = eval("#{arg["class"]}.find '#{arg['obj']['_id']}'")
|
||||
# imp = new(@request,arg["controller_name"],arg["action_name"],arg["user"],obj)
|
||||
new_impression = obj.impressions.build(:user_id=>arg["user"],:controller_name=>arg["controller_name"],:action_name=>arg["action_name"],:ip_address=>@request.remote_ip,:referrer=>@request.referer)
|
||||
@try = 1
|
||||
loop do
|
||||
result = new_impression.save rescue false
|
||||
break if (result || @try >= 10)
|
||||
@try = @try + 1
|
||||
puts "trying:#{@try}"
|
||||
end
|
||||
new_impression.save
|
||||
obj.update_attribute(:view_count,obj.impression_count)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue