Use report_range method in admin/tags to generate reporting period (#35465)

This commit is contained in:
Matt Jankowski 2025-07-23 04:02:07 -04:00 committed by GitHub
parent d065ec9298
commit d2ef9ac04a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ module Admin
before_action :set_tag, except: [:index] before_action :set_tag, except: [:index]
PER_PAGE = 20 PER_PAGE = 20
PERIOD_DAYS = 6.days
def index def index
authorize :tag, :index? authorize :tag, :index?
@ -15,7 +16,7 @@ module Admin
def show def show
authorize @tag, :show? authorize @tag, :show?
@time_period = (6.days.ago.to_date...Time.now.utc.to_date) @time_period = report_range
end end
def update def update
@ -24,7 +25,7 @@ module Admin
if @tag.update(tag_params.merge(reviewed_at: Time.now.utc)) if @tag.update(tag_params.merge(reviewed_at: Time.now.utc))
redirect_to admin_tag_path(@tag.id), notice: I18n.t('admin.tags.updated_msg') redirect_to admin_tag_path(@tag.id), notice: I18n.t('admin.tags.updated_msg')
else else
@time_period = (6.days.ago.to_date...Time.now.utc.to_date) @time_period = report_range
render :show render :show
end end
@ -36,6 +37,10 @@ module Admin
@tag = Tag.find(params[:id]) @tag = Tag.find(params[:id])
end end
def report_range
(PERIOD_DAYS.ago.to_date...Time.now.utc.to_date)
end
def tag_params def tag_params
params params
.expect(tag: [:name, :display_name, :trendable, :usable, :listable]) .expect(tag: [:name, :display_name, :trendable, :usable, :listable])