From 514c57ce5827c343678ed60498eefc929778676a Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 9 Dec 2021 23:08:29 -0600 Subject: [PATCH] api: add rate limit to /explore/posts/popular.json endpoint. Add a rate limit of 1 request per minute to the /explore/posts/popular.json endpoint. This is to deal with a particular bot checking this page multiple times per second. --- app/controllers/explore/posts_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/explore/posts_controller.rb b/app/controllers/explore/posts_controller.rb index f733bf6e1..20e289356 100644 --- a/app/controllers/explore/posts_controller.rb +++ b/app/controllers/explore/posts_controller.rb @@ -2,6 +2,8 @@ module Explore class PostsController < ApplicationController respond_to :html, :xml, :json + rate_limit :popular, rate: 1.0/1.minute, burst: 50, if: -> { request.format.json? }, key: "explore:popular.json" + def popular @date, @scale, @min_date, @max_date = parse_date(params)