discourse/app/models/concerns/reports/bookmarks.rb
Ted Johansson 72ea73988c
DEV: Add missing report filter type in bookmarks report (#22616)
Adding a filter without a type parameter has been deprecated for the last three years, and was marked for removal in 2.9.0.

During this time we have had a few deprecation warnings in logs coming from Reports::Bookmarks.

The fallback was to set the type to the name of the filter. This change just passes the type (same as name) explicitly instead, and removes the deprecation fallback.
2023-07-18 11:07:01 +08:00

25 lines
644 B
Ruby

# frozen_string_literal: true
module Reports::Bookmarks
extend ActiveSupport::Concern
class_methods do
def report_bookmarks(report)
report.icon = "bookmark"
category_filter = report.filters.dig(:category)
report.add_filter("category", type: "category", default: category_filter)
report.data = []
Bookmark
.count_per_day(
category_id: category_filter,
start_date: report.start_date,
end_date: report.end_date,
)
.each { |date, count| report.data << { x: date, y: count } }
add_counts report, Bookmark, "bookmarks.created_at"
end
end
end