Service have been added to /statistics.json
Services have been added to /statistics.json tidying up edits
This commit is contained in:
parent
0127852936
commit
de069962b3
2 changed files with 40 additions and 18 deletions
|
|
@ -17,9 +17,15 @@ class StatisticsPresenter
|
|||
if AppConfig.privacy.statistics.comment_counts?
|
||||
result['local_comments'] = self.local_comments
|
||||
end
|
||||
|
||||
AppConfig.services.each do |service, options|
|
||||
result[service] = options ? !!options["enable"] : false
|
||||
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
||||
def local_posts
|
||||
Post.where(:type => "StatusMessage").joins(:author).where("owner_id IS NOT null").count
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,29 +18,45 @@ describe StatisticsPresenter do
|
|||
AppConfig.privacy.statistics.user_counts = false
|
||||
AppConfig.privacy.statistics.post_counts = false
|
||||
AppConfig.privacy.statistics.comment_counts = false
|
||||
@presenter.as_json.should == {
|
||||
"name" => AppConfig.settings.pod_name,
|
||||
"version" => AppConfig.version_string,
|
||||
"registrations_open" => AppConfig.settings.enable_registrations
|
||||
}
|
||||
end
|
||||
|
||||
it 'provides generic pod data and counts in json' do
|
||||
AppConfig.privacy.statistics.user_counts = true
|
||||
AppConfig.privacy.statistics.post_counts = true
|
||||
AppConfig.privacy.statistics.comment_counts = true
|
||||
|
||||
AppConfig.services = {"facebook" => nil}
|
||||
@presenter.as_json.should == {
|
||||
"name" => AppConfig.settings.pod_name,
|
||||
"version" => AppConfig.version_string,
|
||||
"registrations_open" => AppConfig.settings.enable_registrations,
|
||||
"total_users" => User.count,
|
||||
"active_users_halfyear" => User.halfyear_actives.count,
|
||||
"active_users_monthly" => User.monthly_actives.count,
|
||||
"local_posts" => @presenter.local_posts,
|
||||
"local_comments" => @presenter.local_comments
|
||||
"facebook" => false
|
||||
}
|
||||
end
|
||||
|
||||
context 'when services are enabled' do
|
||||
before do
|
||||
AppConfig.privacy.statistics.user_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
|
||||
|
||||
it 'provides generic pod data and counts in json' do
|
||||
@presenter.as_json.should == {
|
||||
"name" => AppConfig.settings.pod_name,
|
||||
"version" => AppConfig.version_string,
|
||||
"registrations_open" => AppConfig.settings.enable_registrations,
|
||||
"total_users" => User.count,
|
||||
"active_users_halfyear" => User.halfyear_actives.count,
|
||||
"active_users_monthly" => User.monthly_actives.count,
|
||||
"local_posts" => @presenter.local_posts,
|
||||
"local_comments" => @presenter.local_comments,
|
||||
"facebook" => true,
|
||||
"twitter" => true,
|
||||
"tumblr" => false,
|
||||
"wordpress" => false
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue