FIX: dashboard posts report was including posts in daily data, but not in totals

This commit is contained in:
Neil Lalonde 2017-11-02 18:24:43 -04:00
parent c107e99138
commit c7d7cb940c
2 changed files with 2 additions and 0 deletions

View File

@ -622,6 +622,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.group('date(posts.created_at)').order('date(posts.created_at)').count
end

View File

@ -215,6 +215,7 @@ describe Report do
post.topic.add_small_action(Fabricate(:admin), "invited_group", 'coolkids')
r = Report.find('posts')
expect(r.total).to eq(1)
expect(r.data[0][:y]).to eq(1)
end
end
end