def rate_limit_user(request, user, domain):
 (ratelimited, time) = is_ratelimited(user, domain)
 request._ratelimit_applied_limits = True
 request._ratelimit_secs_to_freedom = time
 request._ratelimit_over_limit = ratelimited
 if ratelimited:
  statsd.incr(('ratelimiter.limited.%s.%s' % (type(user), user.id)))
  raise RateLimited()
 incr_ratelimit(user, domain)
 (calls_remaining, time_reset) = api_calls_left(user, domain)
 request._ratelimit_remaining = calls_remaining
 request._ratelimit_secs_to_freedom = time_reset

def rate_limit_user ( request , user , domain ) : ( ratelimited , time ) = is_ratelimited ( user , domain ) request . _ratelimit_applied_limits = True request . _ratelimit_secs_to_freedom = time request . _ratelimit_over_limit = ratelimited if ratelimited : statsd . incr ( ( 'ratelimiter.limited.%s.%s' % ( type ( user ) , user . id ) ) ) raise RateLimited ( ) incr_ratelimit ( user , domain ) ( calls_remaining , time_reset ) = api_calls_left ( user , domain ) request . _ratelimit_remaining = calls_remaining request . _ratelimit_secs_to_freedom = time_reset
returns whether or not a user was rate limited .