From a453aee44ba29317dbbae0ed281d74eb7d87771a Mon Sep 17 00:00:00 2001 From: Andy Zhao <17884966+Zhao-Andy@users.noreply.github.com> Date: Thu, 9 Apr 2020 10:57:45 -0400 Subject: [PATCH] [deploy] Revert refactor of increment back to read/write (#7194) --- app/labor/rate_limit_checker.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/labor/rate_limit_checker.rb b/app/labor/rate_limit_checker.rb index 3dec8064a..4a3c2152f 100644 --- a/app/labor/rate_limit_checker.rb +++ b/app/labor/rate_limit_checker.rb @@ -21,11 +21,15 @@ class RateLimitChecker end def track_image_uploads - Rails.cache.increment("#{@user.id}_image_upload", expires_in: 30.seconds) + count = Rails.cache.read("#{@user.id}_image_upload").to_i + count += 1 + Rails.cache.write("#{@user.id}_image_upload", count, expires_in: 30.seconds) end def track_article_updates - Rails.cache.increment("#{@user.id}_article_update", expires_in: 1.day) + count = Rails.cache.read("#{@user.id}_article_update").to_i + count += 1 + Rails.cache.write("#{@user.id}_article_update", count, expires_in: 1.day) end def limit_by_email_recipient_address(address)