Merge pull request #5351 from MarcBurt/5041-Total-user-statistic-shouldnt-include-closed-accounts

5041 total user statistic shouldnt include closed accounts
This commit is contained in:
Jonne Haß 2015-02-27 16:01:34 +01:00
commit 95053ccbf2
5 changed files with 22 additions and 3 deletions

View file

@ -135,6 +135,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
* Fix code overflow for the mobile website [#5675](https://github.com/diaspora/diaspora/pull/5675)
* Strip Unicode format characters prior post processing [#5680](https://github.com/diaspora/diaspora/pull/5680)
* Disable email notifications for closed user accounts [#5640](https://github.com/diaspora/diaspora/pull/5640)
* Total user statistic no longer includes closed accounts [#5041](https://github.com/diaspora/diaspora/pull/5041)
## Features
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)

View file

@ -526,6 +526,11 @@ class User < ActiveRecord::Base
end
end
def self.total_users
User.joins(:person).where(:people => {:closed_account => false}).where.not(:username => nil)
end
private
def clearable_fields
self.attributes.keys - ["id", "username", "encrypted_password",

View file

@ -122,4 +122,4 @@ class StatisticsPresenter
}
end
end
end

View file

@ -1089,5 +1089,18 @@ describe User, :type => :model do
@user.after_database_authentication
expect(@user.remove_after).to eq(nil)
end
describe "total_users" do
before do
@user1 = FactoryGirl.build(:user, :username => nil)
@user1.save(:validate => false)
@user2 = FactoryGirl.create(:user)
@user2.person.closed_account = true
@user2.save
end
it "returns total_users excluding closed accounts & users without usernames" do
expect(User.total_users.count).to eq 5 #5 users from fixtures
end
end
end

View file

@ -51,8 +51,8 @@ describe StatisticsPresenter do
"name" => AppConfig.settings.pod_name,
"network" => "Diaspora",
"version" => AppConfig.version_string,
"registrations_open" => AppConfig.settings.enable_registrations?,
"total_users" => User.count,
"registrations_open" => AppConfig.settings.enable_registrations,
"total_users" => User.total_users.count,
"active_users_halfyear" => User.halfyear_actives.count,
"active_users_monthly" => User.monthly_actives.count,
"local_posts" => @presenter.local_posts,