FEATURE: Allow admins to force refresh "What's new?" (#29911)

Sometimes changes to "What's new?" feed items are made or the feed items are
removed altogether, and the polling interval to check for new features is 1 day.

This is quite long, so this commit introduces a "Check for updates"
button for admins to click on the "What's new?" page which will bust
the cache for the feed and check again at the new features endpoint.
This is limited to 5 times per minute to avoid rapid sending of
requests.
This commit is contained in:
Martin Brennan
2024-11-27 09:40:55 +10:00
committed by GitHub
parent b9f183e2c3
commit 2ef9d6ac47
9 changed files with 142 additions and 48 deletions

View File

@ -31,7 +31,19 @@ class Admin::DashboardController < Admin::StaffController
end
def new_features
new_features = DiscourseUpdates.new_features
force_refresh = params[:force_refresh] == "true"
if force_refresh
RateLimiter.new(
current_user,
"force-refresh-new-features",
5,
1.minute,
apply_limit_to_staff: true,
).performed!
end
new_features = DiscourseUpdates.new_features(force_refresh:)
if current_user.admin? && most_recent = new_features&.first
DiscourseUpdates.bump_last_viewed_feature_date(current_user.id, most_recent["created_at"])