2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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
|
|
|
|
2020-04-22 16:52:50 +08:00
|
|
|
category_id, include_subcategories = report.add_category_filter
|
2019-04-26 18:17:10 +08:00
|
|
|
|
2020-04-22 16:52:50 +08:00
|
|
|
basic_report_about report, Post, :public_posts_count_per_day, report.start_date, report.end_date, category_id, include_subcategories
|
2019-04-26 18:17:10 +08:00
|
|
|
|
2019-03-29 17:54:56 +08:00
|
|
|
countable = Post.public_posts.where(post_type: Post.types[:regular])
|
2020-04-22 16:52:50 +08:00
|
|
|
if category_id
|
|
|
|
if include_subcategories
|
|
|
|
countable = countable.joins(:topic).where('topics.category_id IN (?)', Category.subcategory_ids(category_id))
|
|
|
|
else
|
|
|
|
countable = countable.joins(:topic).where('topics.category_id = ?', category_id)
|
|
|
|
end
|
2019-03-29 17:54:56 +08:00
|
|
|
end
|
2020-04-22 16:52:50 +08:00
|
|
|
|
2019-03-29 17:54:56 +08:00
|
|
|
add_counts report, countable, 'posts.created_at'
|
|
|
|
end
|