From 7b53ddad2b2ebb08bea0533988e9586fcda5eca6 Mon Sep 17 00:00:00 2001 From: Noah Davis Date: Wed, 21 Oct 2015 15:25:54 -0700 Subject: [PATCH 1/2] Fixes --- app/models/application_request.rb | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/app/models/application_request.rb b/app/models/application_request.rb index 8f146f10fd78c..a5cbac28aec44 100644 --- a/app/models/application_request.rb +++ b/app/models/application_request.rb @@ -37,36 +37,6 @@ def self.increment!(type, opts=nil) end def self.write_cache!(date=nil) - if date.nil? - write_cache!(Time.now.utc) - write_cache!(Time.now.utc.yesterday) - return - end - - self.last_flush = Time.now.utc - - date = date.to_date - - # this may seem a bit fancy but in so it allows - # for concurrent calls without double counting - req_types.each do |req_type,_| - key = redis_key(req_type,date) - val = $redis.get(key).to_i - - next if val == 0 - - new_val = $redis.incrby(key, -val).to_i - - if new_val < 0 - # undo and flush next time - $redis.incrby(key, val) - next - end - - id = req_id(date,req_type) - - where(id: id).update_all(["count = count + ?", val]) - end end def self.clear_cache!(date=nil) @@ -82,8 +52,6 @@ def self.clear_cache!(date=nil) end end - protected - def self.req_id(date,req_type,retries=0) req_type_id = req_types[req_type] From 2fbcbf888cda273296c90356b421b23c71955733 Mon Sep 17 00:00:00 2001 From: Noah Davis Date: Wed, 21 Oct 2015 16:14:56 -0700 Subject: [PATCH 2/2] testing --- noah.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 noah.md diff --git a/noah.md b/noah.md new file mode 100644 index 0000000000000..e69de29bb2d1d