Created
February 2, 2021 11:08
-
-
Save daniel-sim/c1d11e21ee5499dd81bbce7995bdb276 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def throttle(start_time) | |
stop_time = Time.zone.now | |
processing_duration = stop_time - start_time | |
wait_time = (0.3 - processing_duration).round(1) | |
Rails.logger.info("THROTTLING: #{wait_time}") | |
sleep wait_time if wait_time > 0.0 | |
Time.zone.now | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment