Skip to content

Commit

Permalink
Merge branch 'kb_development' into kbtopic-600-add-ng-rule
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Feb 20, 2024
2 parents afd8704 + 68eddba commit cc7a931
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions app/helpers/registration_limitation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ def today_increase_user_count_value
end

def registrations_in_time?
start_hour = Setting.registrations_start_hour || 0
end_hour = Setting.registrations_end_hour || 24
secondary_start_hour = Setting.registrations_secondary_start_hour || 0
secondary_end_hour = Setting.registrations_secondary_end_hour || 0
start_hour = Setting.registrations_start_hour
end_hour = Setting.registrations_end_hour
secondary_start_hour = Setting.registrations_secondary_start_hour
secondary_end_hour = Setting.registrations_secondary_end_hour

start_hour = 0 unless start_hour.is_a?(Integer)
end_hour = 0 unless end_hour.is_a?(Integer)
secondary_start_hour = 0 unless secondary_start_hour.is_a?(Integer)
secondary_end_hour = 0 unless secondary_end_hour.is_a?(Integer)

return true if start_hour >= end_hour && secondary_start_hour >= secondary_end_hour

current_hour = Time.now.utc.hour
primary_permitted = false
primary_permitted = start_hour <= current_hour && current_hour < end_hour if start_hour < end_hour && end_hour.positive?
secondary_permitted = false
secondary_permitted = secondary_start_hour <= current_hour && current_hour < secondary_end_hour if secondary_start_hour < secondary_end_hour && secondary_end_hour.positive?

primary_permitted || secondary_permitted
(start_hour < end_hour && end_hour.positive? && current_hour.between?(start_hour, end_hour - 1)) ||
(secondary_start_hour < secondary_end_hour && secondary_end_hour.positive? && current_hour.between?(secondary_start_hour, secondary_end_hour - 1))
end

def reset_registration_limit_caches!
Expand Down

0 comments on commit cc7a931

Please sign in to comment.