2019-04-26 18:17:10 +08:00
|
|
|
Report.add_report('posts') do |report|
|
2019-03-29 17:54:56 +08:00
|
|
|
report.modes = [:table, :chart]
|
2019-04-26 18:17:10 +08:00
|
|
|
|
|
|
|
category_filter = report.filters.dig(:category)
|
|
|
|
report.add_filter('category', default: category_filter)
|
|
|
|
|
|
|
|
basic_report_about report, Post, :public_posts_count_per_day, report.start_date, report.end_date, category_filter
|
|
|
|
|
2019-03-29 17:54:56 +08:00
|
|
|
countable = Post.public_posts.where(post_type: Post.types[:regular])
|
2019-04-26 18:17:10 +08:00
|
|
|
if category_filter
|
|
|
|
countable = countable.joins(:topic).merge(Topic.in_category_and_subcategories(category_filter))
|
2019-03-29 17:54:56 +08:00
|
|
|
end
|
|
|
|
add_counts report, countable, 'posts.created_at'
|
|
|
|
end
|