Updated

app/jobs/concerns / rate_limiting.rb

A
33 lines of codes
2 methods
9.8 complexity/method
1 churn
19.59 complexity
0 duplications
module RateLimiting
  1. RateLimiting has no descriptive comment
extend ActiveSupport::Concern included do rescue_from(ActiveJob::DeserializationError) do |exception| Appsignal.send_exception exception end end def perform(signature)
  1. RateLimiting#perform has approx 7 statements
if rate_limit.exceeded?(signature) signature.fraudulent! end mailer.send(email, signature).deliver_now updates, params = [], {} updates << "email_count = COALESCE(email_count, 0) + 1" if constituency = signature.constituency updates << "constituency_id = :constituency_id" params[:constituency_id] = constituency.external_id end signature.update_all([updates.join(", "), params]) end private def rate_limit @rate_limit ||= RateLimit.first_or_create! end end