This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/models/concerns/reports/bookmarks.rb
2023-01-09 14:14:59 +00:00

25 lines
626 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", 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