FIX: admin dashboard posts count should not include system posts and whispers
This commit is contained in:
parent
c216f59eaa
commit
c94fdcea38
|
@ -122,7 +122,7 @@ class Report
|
|||
|
||||
def self.report_posts(report)
|
||||
basic_report_about report, Post, :public_posts_count_per_day, report.start_date, report.end_date, report.category_id
|
||||
countable = Post.public_posts
|
||||
countable = Post.public_posts.where(post_type: Post.types[:regular])
|
||||
countable = countable.joins(:topic).where("topics.category_id = ?", report.category_id) if report.category_id
|
||||
add_counts report, countable, 'posts.created_at'
|
||||
end
|
||||
|
|
|
@ -209,5 +209,15 @@ describe Report do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'posts counts' do
|
||||
it "only counts regular posts" do
|
||||
post = Fabricate(:post)
|
||||
Fabricate(:moderator_post, topic: post.topic)
|
||||
Fabricate.build(:post, post_type: Post.types[:whisper], topic: post.topic)
|
||||
post.topic.add_small_action(Fabricate(:admin), "invited_group", 'coolkids')
|
||||
r = Report.find('posts')
|
||||
expect(r.total).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue