From 937dbf11858d2242cecdc09dddc6cc9414e77fee Mon Sep 17 00:00:00 2001 From: Zach Margolis Date: Fri, 3 Feb 2023 10:22:12 -0800 Subject: [PATCH 1/2] Update queries to include notes about accounts that were deleted --- _articles/queries.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/_articles/queries.md b/_articles/queries.md index 5032c666..cfa1cc84 100644 --- a/_articles/queries.md +++ b/_articles/queries.md @@ -17,7 +17,7 @@ ActiveRecord::Base.connection.execute 'SET statement_timeout = 200000' ## Total Registered -Returns the number of users that created accounts (this includes users who may not have fully registered, see [Fully Registered Users](#fully-registered-users) for that query) +Returns the number of users that created accounts (this includes users who may not have fully registered, see [Fully Registered Users](#fully-registered-users) for that query), it does not count users who have already deleted their accounts. ```ruby User.count @@ -30,9 +30,26 @@ date = Date.new(2021, 1, 1) User.where('created_at <= ?', date).count ``` +## Total Registered, Including Deletes + +Returns the number of users who have ever created an account, including ones who may have later deleted their accounts. + +```ruby +User.count + DeletedUser.count +``` + + +To approximate the count at a past point in time, substitute `date` below: + +```ruby +date = Date.new(2021, 1, 1) + +User.where('created_at <= ?', date).count + DeletedUser.where('user_created_at <= ?', date).count +``` + ## Fully Registered Users -Returns the number of fully registered users. +Returns the number of fully registered users. If a user has later deleted their account, they will not be counted. **Note**: This table has been backfilled as far back as 2017, so it is good for all time. From 2c42f19ecb65a2e50d5ebd6a1c9c066568e2939d Mon Sep 17 00:00:00 2001 From: Zach Margolis Date: Fri, 3 Feb 2023 10:50:54 -0800 Subject: [PATCH 2/2] Update _articles/queries.md Co-authored-by: Jessica Dembe --- _articles/queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_articles/queries.md b/_articles/queries.md index cfa1cc84..f0bca5fd 100644 --- a/_articles/queries.md +++ b/_articles/queries.md @@ -17,7 +17,7 @@ ActiveRecord::Base.connection.execute 'SET statement_timeout = 200000' ## Total Registered -Returns the number of users that created accounts (this includes users who may not have fully registered, see [Fully Registered Users](#fully-registered-users) for that query), it does not count users who have already deleted their accounts. +Returns the number of users that created accounts (this includes users who may not have fully registered, see [Fully Registered Users](#fully-registered-users) for that query). The count does not include users who have already deleted their accounts. ```ruby User.count