@@ -26,16 +26,11 @@ def validate
2626 # TODO: uncomment other throttling thresholds once we have fine-tuned those limits
2727 return error ( TOKEN_USED ) unless log_token
2828 return error ( USER_BLOCKED ) if user_blocked?
29- # return error(CLASSROOM_BLOCKED) if teachers_blocked?
29+ return error ( CLASSROOM_BLOCKED ) if teachers_blocked?
3030 hourly_usage_response = user_usage ( ONE_HOUR_SECONDS )
3131 return error ( USER_BLOCKED ) if user_over_hourly_limit? ( hourly_usage_response )
3232 # return error(USER_BLOCKED) if user_over_daily_limit?
33- # return error(CLASSROOM_BLOCKED) if teachers_over_hourly_limit?
34-
35- # for now, check and log if the teacher is over the hourly limit, but still
36- # allow those users through until we fine tune the limit
37- teachers_over_hourly_limit?
38-
33+ return error ( CLASSROOM_BLOCKED ) if teachers_over_hourly_limit?
3934
4035 near_limit_detail = get_user_near_hourly_limit_detail ( hourly_usage_response . count )
4136 log_requests
@@ -130,6 +125,10 @@ def teachers_over_hourly_limit?
130125 puts "teacher_associated_requests query has paginated responses. user_id #{ @user_id } teacher_id #{ teacher_id } "
131126 end
132127
128+ # Log the count of requests per hour to a metric. We are logging this for now so we can determine if we
129+ # have set a good threshold for blocking classrooms.
130+ @metrics_reporter . log_count_with_value ( CLASSROOM_HOURLY_REQUEST_COUNT , response . count )
131+
133132 if response . count > ENV [ 'teacher_limit_per_hour' ] . to_i
134133 begin
135134 @dynamodb_client . put_item (
0 commit comments