Actions
Patch #41023
closedSet default age parameter for User.prune to 30 days
Description
User.prune
is a method to delete users who have not completed registration for a long time.
The method accepts an age
parameter, but the parameter currently does not have a default value. Without a default value, calls to prune could result in unexpected failures if the age argument is inadvertently omitted.
The following patch sets a default value of 30 days for the age parameter in the User.prune method. The value is the same as the default value of the redmine:users:prune
rake task (source:tags/5.1.3/lib/tasks/redmine.rake#L46).
diff --git a/app/models/user.rb b/app/models/user.rb
index 2fae4a7ca..ee1303d41 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -887,7 +887,7 @@ class User < Principal
project_ids.map(&:to_i)
end
- def self.prune(age)
+ def self.prune(age=30.days)
User.where("created_on < ? AND status = ?", Time.now - age, STATUS_REGISTERED).destroy_all
end
Related issues
Updated by Go MAEDA 4 months ago
- Related to Feature #30998: Add an rake task to prune registered users after a certain number of days added
Actions