FIX: Include subcategories in 'posts' report (#9410)

This commit is contained in:
Dan Ungureanu 2020-04-13 18:57:52 +03:00 committed by GitHub
parent a10c36994b
commit 799ddeea3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -767,7 +767,7 @@ class Post < ActiveRecord::Base
def self.public_posts_count_per_day(start_date, end_date, category_id = nil)
result = public_posts.where('posts.created_at >= ? AND posts.created_at <= ?', start_date, end_date)
.where(post_type: Post.types[:regular])
result = result.where('topics.category_id = ?', category_id) if category_id
result = result.where('topics.category_id IN (?)', Category.subcategory_ids(category_id.to_i)) if category_id
result
.group('date(posts.created_at)')
.order('date(posts.created_at)')