added comment count to statistic to calculate posts/comments ratios

fixeds tests for comment count in statistics

added changelog entry and default entry
This commit is contained in:
Jannik Streek 2014-02-20 21:55:01 +01:00
parent 57991187d1
commit d603ff818c
5 changed files with 15 additions and 2 deletions

View file

@ -17,6 +17,7 @@
* Do not add a space after adding a mention [#4767](https://github.com/diaspora/diaspora/issues/4767) * Do not add a space after adding a mention [#4767](https://github.com/diaspora/diaspora/issues/4767)
## Features ## Features
* Added comment count to statistic to enable calculations of posts/comments ratios [#4799](https://github.com/diaspora/diaspora/pull/4799)
* You can report a single post by clicking the correct icon in the controler section [#4517](https://github.com/diaspora/diaspora/pull/4517) * You can report a single post by clicking the correct icon in the controler section [#4517](https://github.com/diaspora/diaspora/pull/4517)
* Add permalinks for comments [#4577](https://github.com/diaspora/diaspora/pull/4577) * Add permalinks for comments [#4577](https://github.com/diaspora/diaspora/pull/4577)
* New menu for the mobile version [#4673](https://github.com/diaspora/diaspora/pull/4673) * New menu for the mobile version [#4673](https://github.com/diaspora/diaspora/pull/4673)

View file

@ -14,11 +14,18 @@ class StatisticsPresenter
if AppConfig.privacy.statistics.post_counts? if AppConfig.privacy.statistics.post_counts?
result['local_posts'] = self.local_posts result['local_posts'] = self.local_posts
end end
if AppConfig.privacy.statistics.comment_counts?
result['local_comments'] = self.local_comments
end
result result
end end
def local_posts def local_posts
Post.where(:type => "StatusMessage").joins(:author).where("owner_id IS NOT null").count Post.where(:type => "StatusMessage").joins(:author).where("owner_id IS NOT null").count
end end
def local_comments
Comment.joins(:author).where("owner_id IS NOT null").count
end
end end

View file

@ -52,6 +52,7 @@ defaults:
statistics: statistics:
user_counts: false user_counts: false
post_counts: false post_counts: false
comment_counts: false
settings: settings:
pod_name: 'diaspora*' pod_name: 'diaspora*'
enable_registrations: true enable_registrations: true

View file

@ -200,6 +200,7 @@ configuration: ## Section
#user_counts: true #user_counts: true
## Local post total count ## Local post total count
#post_counts: true #post_counts: true
#comment_counts: true
## General settings ## General settings
settings: ## Section settings: ## Section

View file

@ -17,6 +17,7 @@ describe StatisticsPresenter do
it 'provides generic pod data in json' do it 'provides generic pod data in json' do
AppConfig.privacy.statistics.user_counts = false AppConfig.privacy.statistics.user_counts = false
AppConfig.privacy.statistics.post_counts = false AppConfig.privacy.statistics.post_counts = false
AppConfig.privacy.statistics.comment_counts = false
@presenter.as_json.should == { @presenter.as_json.should == {
"name" => AppConfig.settings.pod_name, "name" => AppConfig.settings.pod_name,
"version" => AppConfig.version_string, "version" => AppConfig.version_string,
@ -27,7 +28,8 @@ describe StatisticsPresenter do
it 'provides generic pod data and counts in json' do it 'provides generic pod data and counts in json' do
AppConfig.privacy.statistics.user_counts = true AppConfig.privacy.statistics.user_counts = true
AppConfig.privacy.statistics.post_counts = true AppConfig.privacy.statistics.post_counts = true
AppConfig.privacy.statistics.comment_counts = true
@presenter.as_json.should == { @presenter.as_json.should == {
"name" => AppConfig.settings.pod_name, "name" => AppConfig.settings.pod_name,
"version" => AppConfig.version_string, "version" => AppConfig.version_string,
@ -35,7 +37,8 @@ describe StatisticsPresenter do
"total_users" => User.count, "total_users" => User.count,
"active_users_halfyear" => User.halfyear_actives.count, "active_users_halfyear" => User.halfyear_actives.count,
"active_users_monthly" => User.monthly_actives.count, "active_users_monthly" => User.monthly_actives.count,
"local_posts" => @presenter.local_posts "local_posts" => @presenter.local_posts,
"local_comments" => @presenter.local_comments
} }
end end