@@ -196,16 +196,16 @@ def _archive_retirements_or_exit(config, learners, dry_run=False):
196196 FAIL_EXCEPTION (ERR_ARCHIVING , 'Unexpected error occurred archiving retirements!' , exc )
197197
198198
199- def _cleanup_retirements_or_exit (config , learners ):
199+ def _cleanup_retirements_or_exit (config , learners , redacted_username = 'redacted' , redacted_email = 'redacted' , redacted_name = 'redacted' ):
200200 """
201- Bulk deletes the retirements for this run
201+ Bulk redacts the retirements for this run
202202 """
203203 LOG ('Cleaning up retirements for {} learners' .format (len (learners )))
204204 try :
205205 usernames = [l ['original_username' ] for l in learners ]
206- config ['LMS' ].bulk_cleanup_retirements (usernames )
206+ config ['LMS' ].bulk_cleanup_retirements (usernames , redacted_username , redacted_email , redacted_name )
207207 except Exception as exc : # pylint: disable=broad-except
208- FAIL_EXCEPTION (ERR_DELETING , 'Unexpected error occurred deleting retirements!' , exc )
208+ FAIL_EXCEPTION (ERR_DELETING , 'Unexpected error occurred redacting retirements!' , exc )
209209
210210
211211def _get_utc_now ():
@@ -222,7 +222,7 @@ def _get_utc_now():
222222)
223223@click .option (
224224 '--cool_off_days' ,
225- help = 'Number of days a retirement should exist before being archived and deleted .' ,
225+ help = 'Number of days a retirement should exist before being archived and redacted .' ,
226226 type = int ,
227227 default = 37 # 7 days before retirement, 30 after
228228)
@@ -259,7 +259,25 @@ def _get_utc_now():
259259 help = 'Number of user retirements to process' ,
260260 type = int
261261)
262- def archive_and_cleanup (config_file , cool_off_days , dry_run , start_date , end_date , batch_size ):
262+ @click .option (
263+ '--redacted_username' ,
264+ help = 'Value to redact username field with' ,
265+ type = str ,
266+ default = 'redacted'
267+ )
268+ @click .option (
269+ '--redacted_email' ,
270+ help = 'Value to redact email field with' ,
271+ type = str ,
272+ default = 'redacted'
273+ )
274+ @click .option (
275+ '--redacted_name' ,
276+ help = 'Value to redact name field with' ,
277+ type = str ,
278+ default = 'redacted'
279+ )
280+ def archive_and_cleanup (config_file , cool_off_days , dry_run , start_date , end_date , batch_size , redacted_username , redacted_email , redacted_name ):
263281 """
264282 Cleans up UserRetirementStatus rows in LMS by:
265283 1- Getting all rows currently in COMPLETE that were created --cool_off_days ago or more,
@@ -314,7 +332,7 @@ def archive_and_cleanup(config_file, cool_off_days, dry_run, start_date, end_dat
314332 if dry_run :
315333 LOG ('This is a dry-run. Exiting before any retirements are cleaned up' )
316334 else :
317- _cleanup_retirements_or_exit (config , batch )
335+ _cleanup_retirements_or_exit (config , batch , redacted_username , redacted_email , redacted_name )
318336 LOG ('Archive and cleanup complete for batch #{}' .format (str (index + 1 )))
319337 time .sleep (DELAY )
320338 else :
0 commit comments