Project

General

Profile

Actions

Patch #41023

closed

Set default age parameter for User.prune to 30 days

Added by Go MAEDA 5 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

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

Related to Redmine - Feature #30998: Add an rake task to prune registered users after a certain number of daysClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA 5 months ago

  • Related to Feature #30998: Add an rake task to prune registered users after a certain number of days added
Actions #2

Updated by Go MAEDA 5 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch in r22938.

Actions

Also available in: Atom PDF