Skip to content

Commit

Permalink
Rewrite new registrations query with timeframe
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Dec 11, 2023
1 parent 581cacf commit c5b624e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ def after_sign_up_path_for(_resource)
private

def check_registration_limit
timeframe = (ENV["MAMPF_REGISTRATION_TIMEFRAME"] || 15).to_i.minutes
threshold_date = DateTime.now - timeframe
num_new_registrations = User.where(
"users.confirmed_at is NULL and users.created_at > '#{threshold_date}'"
).count

timeframe = ((ENV["MAMPF_REGISTRATION_TIMEFRAME"] || 15).to_i.minutes.ago..)
num_new_registrations = User.where(confirmed_at: nil, created_at: timeframe).count
max_registrations = (ENV["MAMPF_MAX_REGISTRATION_PER_TIMEFRAME"] || 40).to_i
return if num_new_registrations <= max_registrations

Expand Down

0 comments on commit c5b624e

Please sign in to comment.