Moved services to a JSON list.
Added AppConfig.privacy.statistics.deprecated_format to toggle showing the old style format.
This commit is contained in:
parent
86ce99418f
commit
03f3c74cee
4 changed files with 15 additions and 7 deletions
|
|
@ -4,7 +4,8 @@ class StatisticsPresenter
|
||||||
result = {
|
result = {
|
||||||
'name' => AppConfig.settings.pod_name,
|
'name' => AppConfig.settings.pod_name,
|
||||||
'version' => AppConfig.version_string,
|
'version' => AppConfig.version_string,
|
||||||
'registrations_open' => AppConfig.settings.enable_registrations
|
'registrations_open' => AppConfig.settings.enable_registrations,
|
||||||
|
'services' => []
|
||||||
}
|
}
|
||||||
if AppConfig.privacy.statistics.user_counts?
|
if AppConfig.privacy.statistics.user_counts?
|
||||||
result['total_users'] = User.count
|
result['total_users'] = User.count
|
||||||
|
|
@ -17,9 +18,12 @@ class StatisticsPresenter
|
||||||
if AppConfig.privacy.statistics.comment_counts?
|
if AppConfig.privacy.statistics.comment_counts?
|
||||||
result['local_comments'] = self.local_comments
|
result['local_comments'] = self.local_comments
|
||||||
end
|
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|
|
Configuration::KNOWN_SERVICES.each do |service, options|
|
||||||
result[service.to_s] = AppConfig["services.#{service}.enable"]
|
result[service.to_s] = AppConfig["services.#{service}.enable"]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ defaults:
|
||||||
user_counts: false
|
user_counts: false
|
||||||
post_counts: false
|
post_counts: false
|
||||||
comment_counts: false
|
comment_counts: false
|
||||||
|
deprecated_format: true
|
||||||
settings:
|
settings:
|
||||||
pod_name: 'diaspora*'
|
pod_name: 'diaspora*'
|
||||||
enable_registrations: true
|
enable_registrations: true
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,9 @@ configuration: ## Section
|
||||||
#post_counts: true
|
#post_counts: true
|
||||||
#comment_counts: true
|
#comment_counts: true
|
||||||
|
|
||||||
|
## Also show old services block (enabled by default)
|
||||||
|
#deprecated_format: false
|
||||||
|
|
||||||
## General settings
|
## General settings
|
||||||
settings: ## Section
|
settings: ## Section
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ describe StatisticsPresenter 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
|
AppConfig.privacy.statistics.comment_counts = false
|
||||||
|
AppConfig.privacy.statistics.deprecated_format = false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'provides generic pod data in json' do
|
it 'provides generic pod data in json' do
|
||||||
|
|
@ -24,10 +25,7 @@ describe StatisticsPresenter do
|
||||||
"name" => AppConfig.settings.pod_name,
|
"name" => AppConfig.settings.pod_name,
|
||||||
"version" => AppConfig.version_string,
|
"version" => AppConfig.version_string,
|
||||||
"registrations_open" => AppConfig.settings.enable_registrations,
|
"registrations_open" => AppConfig.settings.enable_registrations,
|
||||||
"facebook" => true,
|
"services"=> ["facebook",]
|
||||||
"twitter" => false,
|
|
||||||
"tumblr" => false,
|
|
||||||
"wordpress" => false,
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -36,6 +34,7 @@ describe StatisticsPresenter 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
|
AppConfig.privacy.statistics.comment_counts = true
|
||||||
|
AppConfig.privacy.statistics.deprecated_format = true
|
||||||
AppConfig.services = {
|
AppConfig.services = {
|
||||||
"facebook" => {"enable" => true},
|
"facebook" => {"enable" => true},
|
||||||
"twitter" => {"enable" => true},
|
"twitter" => {"enable" => true},
|
||||||
|
|
@ -54,6 +53,7 @@ describe StatisticsPresenter do
|
||||||
"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,
|
"local_comments" => @presenter.local_comments,
|
||||||
|
"services" => ["twitter","facebook"],
|
||||||
"facebook" => true,
|
"facebook" => true,
|
||||||
"twitter" => true,
|
"twitter" => true,
|
||||||
"tumblr" => false,
|
"tumblr" => false,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue