Skip to content
Extraits de code Groupes Projets
Valider de069962 rédigé par damzcodes's avatar damzcodes
Parcourir les fichiers

Service have been added to /statistics.json

Services have been added to /statistics.json

tidying up

edits
parent 01278529
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -17,9 +17,15 @@ class StatisticsPresenter ...@@ -17,9 +17,15 @@ 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
AppConfig.services.each do |service, options|
result[service] = options ? !!options["enable"] : false
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
......
...@@ -18,28 +18,44 @@ describe StatisticsPresenter do ...@@ -18,28 +18,44 @@ 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.services = {"facebook" => nil}
@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,
"registrations_open" => AppConfig.settings.enable_registrations "registrations_open" => AppConfig.settings.enable_registrations,
"facebook" => false
} }
end end
it 'provides generic pod data and counts in json' do context 'when services are enabled' do
AppConfig.privacy.statistics.user_counts = true before do
AppConfig.privacy.statistics.post_counts = true AppConfig.privacy.statistics.user_counts = true
AppConfig.privacy.statistics.comment_counts = true AppConfig.privacy.statistics.post_counts = true
AppConfig.privacy.statistics.comment_counts = true
AppConfig.services = {
"facebook" => {"enable" => true},
"twitter" => {"enable" => true},
"wordpress" => {"enable" => false},
"tumblr" => {"enable" => false}
}
end
@presenter.as_json.should == { it 'provides generic pod data and counts in json' do
"name" => AppConfig.settings.pod_name, @presenter.as_json.should == {
"version" => AppConfig.version_string, "name" => AppConfig.settings.pod_name,
"registrations_open" => AppConfig.settings.enable_registrations, "version" => AppConfig.version_string,
"total_users" => User.count, "registrations_open" => AppConfig.settings.enable_registrations,
"active_users_halfyear" => User.halfyear_actives.count, "total_users" => User.count,
"active_users_monthly" => User.monthly_actives.count, "active_users_halfyear" => User.halfyear_actives.count,
"local_posts" => @presenter.local_posts, "active_users_monthly" => User.monthly_actives.count,
"local_comments" => @presenter.local_comments "local_posts" => @presenter.local_posts,
} "local_comments" => @presenter.local_comments,
"facebook" => true,
"twitter" => true,
"tumblr" => false,
"wordpress" => false
}
end
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter