2020-10-30 00:49:09 +08:00
|
|
|
# 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)
|
2023-07-18 11:07:01 +08:00
|
|
|
report.add_filter("category", type: "category", default: category_filter)
|
2020-10-30 00:49:09 +08:00
|
|
|
|
|
|
|
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
|