From 03f3c74ceefdfc1077203c831643180c51e032cf Mon Sep 17 00:00:00 2001 From: Alex Nordlund Date: Sun, 5 Oct 2014 01:07:30 +0200 Subject: [PATCH 1/2] Moved services to a JSON list. Added AppConfig.privacy.statistics.deprecated_format to toggle showing the old style format. --- app/presenters/statistics_presenter.rb | 10 +++++++--- config/defaults.yml | 1 + config/diaspora.yml.example | 3 +++ spec/presenters/statistics_presenter_spec.rb | 8 ++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/presenters/statistics_presenter.rb b/app/presenters/statistics_presenter.rb index a3bcb8b32..199d64b67 100644 --- a/app/presenters/statistics_presenter.rb +++ b/app/presenters/statistics_presenter.rb @@ -4,7 +4,8 @@ class StatisticsPresenter result = { 'name' => AppConfig.settings.pod_name, 'version' => AppConfig.version_string, - 'registrations_open' => AppConfig.settings.enable_registrations + 'registrations_open' => AppConfig.settings.enable_registrations, + 'services' => [] } if AppConfig.privacy.statistics.user_counts? result['total_users'] = User.count @@ -17,8 +18,11 @@ class StatisticsPresenter if AppConfig.privacy.statistics.comment_counts? result['local_comments'] = self.local_comments end - Configuration::KNOWN_SERVICES.each do |service, options| - result[service.to_s] = AppConfig["services.#{service}.enable"] + result["services"] = Configuration::KNOWN_SERVICES.select {|service| AppConfig["services.#{service}.enable"]}.map(&:to_s) + if AppConfig.privacy.statistics.deprecated_format? + Configuration::KNOWN_SERVICES.each do |service, options| + result[service.to_s] = AppConfig["services.#{service}.enable"] + end end result diff --git a/config/defaults.yml b/config/defaults.yml index 01e2599be..d30c2e009 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -53,6 +53,7 @@ defaults: user_counts: false post_counts: false comment_counts: false + deprecated_format: true settings: pod_name: 'diaspora*' enable_registrations: true diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example index 0555ee9bc..4438d5e6a 100644 --- a/config/diaspora.yml.example +++ b/config/diaspora.yml.example @@ -209,6 +209,9 @@ configuration: ## Section ## Local post total count #post_counts: true #comment_counts: true + + ## Also show old services block (enabled by default) + #deprecated_format: false ## General settings settings: ## Section diff --git a/spec/presenters/statistics_presenter_spec.rb b/spec/presenters/statistics_presenter_spec.rb index a020463b1..3debcb598 100644 --- a/spec/presenters/statistics_presenter_spec.rb +++ b/spec/presenters/statistics_presenter_spec.rb @@ -17,6 +17,7 @@ describe StatisticsPresenter do AppConfig.privacy.statistics.user_counts = false AppConfig.privacy.statistics.post_counts = false AppConfig.privacy.statistics.comment_counts = false + AppConfig.privacy.statistics.deprecated_format = false end it 'provides generic pod data in json' do @@ -24,10 +25,7 @@ describe StatisticsPresenter do "name" => AppConfig.settings.pod_name, "version" => AppConfig.version_string, "registrations_open" => AppConfig.settings.enable_registrations, - "facebook" => true, - "twitter" => false, - "tumblr" => false, - "wordpress" => false, + "services"=> ["facebook",] }) end @@ -36,6 +34,7 @@ describe StatisticsPresenter do AppConfig.privacy.statistics.user_counts = true AppConfig.privacy.statistics.post_counts = true AppConfig.privacy.statistics.comment_counts = true + AppConfig.privacy.statistics.deprecated_format = true AppConfig.services = { "facebook" => {"enable" => true}, "twitter" => {"enable" => true}, @@ -54,6 +53,7 @@ describe StatisticsPresenter do "active_users_monthly" => User.monthly_actives.count, "local_posts" => @presenter.local_posts, "local_comments" => @presenter.local_comments, + "services" => ["twitter","facebook"], "facebook" => true, "twitter" => true, "tumblr" => false, From acc7377e5f3b2b0df39d3d09ca8525ec38911d7e Mon Sep 17 00:00:00 2001 From: Alex Nordlund Date: Sun, 5 Oct 2014 01:45:48 +0200 Subject: [PATCH 2/2] Removed setting for statistics, showing both instead. --- app/presenters/statistics_presenter.rb | 6 ++---- config/defaults.yml | 1 - config/diaspora.yml.example | 3 --- spec/presenters/statistics_presenter_spec.rb | 8 +++++--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/presenters/statistics_presenter.rb b/app/presenters/statistics_presenter.rb index 199d64b67..f723fc639 100644 --- a/app/presenters/statistics_presenter.rb +++ b/app/presenters/statistics_presenter.rb @@ -19,10 +19,8 @@ class StatisticsPresenter result['local_comments'] = self.local_comments end result["services"] = Configuration::KNOWN_SERVICES.select {|service| AppConfig["services.#{service}.enable"]}.map(&:to_s) - if AppConfig.privacy.statistics.deprecated_format? - Configuration::KNOWN_SERVICES.each do |service, options| - result[service.to_s] = AppConfig["services.#{service}.enable"] - end + Configuration::KNOWN_SERVICES.each do |service, options| + result[service.to_s] = AppConfig["services.#{service}.enable"] end result diff --git a/config/defaults.yml b/config/defaults.yml index d30c2e009..01e2599be 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -53,7 +53,6 @@ defaults: user_counts: false post_counts: false comment_counts: false - deprecated_format: true settings: pod_name: 'diaspora*' enable_registrations: true diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example index 4438d5e6a..d0f26efbb 100644 --- a/config/diaspora.yml.example +++ b/config/diaspora.yml.example @@ -210,9 +210,6 @@ configuration: ## Section #post_counts: true #comment_counts: true - ## Also show old services block (enabled by default) - #deprecated_format: false - ## General settings settings: ## Section diff --git a/spec/presenters/statistics_presenter_spec.rb b/spec/presenters/statistics_presenter_spec.rb index 3debcb598..ebd6e2ff7 100644 --- a/spec/presenters/statistics_presenter_spec.rb +++ b/spec/presenters/statistics_presenter_spec.rb @@ -17,7 +17,6 @@ describe StatisticsPresenter do AppConfig.privacy.statistics.user_counts = false AppConfig.privacy.statistics.post_counts = false AppConfig.privacy.statistics.comment_counts = false - AppConfig.privacy.statistics.deprecated_format = false end it 'provides generic pod data in json' do @@ -25,7 +24,11 @@ describe StatisticsPresenter do "name" => AppConfig.settings.pod_name, "version" => AppConfig.version_string, "registrations_open" => AppConfig.settings.enable_registrations, - "services"=> ["facebook",] + "services"=> ["facebook",], + "facebook" => true, + "tumblr" => false, + "twitter" => false, + "wordpress" => false, }) end @@ -34,7 +37,6 @@ describe StatisticsPresenter do AppConfig.privacy.statistics.user_counts = true AppConfig.privacy.statistics.post_counts = true AppConfig.privacy.statistics.comment_counts = true - AppConfig.privacy.statistics.deprecated_format = true AppConfig.services = { "facebook" => {"enable" => true}, "twitter" => {"enable" => true},