<commit_before>SET FOREIGN_KEY_CHECKS=0;

/*
  Rewrite all emails to used the SES simulator, simulating success.
  Anonymize other user information
*/

UPDATE wwc.auth_user
    set email = concat('success+',cast(id AS CHAR),'<EMAIL>')
        where email not like ('<EMAIL>'),
    set username = concat('user-',cast(id AS CHAR))
        where email not like ('<EMAIL>'),
    set first_name = concat('user-',cast(id AS CHAR))
        where email not like ('<EMAIL>'),
    set last_name = concat('user-',cast(id AS CHAR))
        where email not like ('<EMAIL>'),
    set password = <PASSWORD>
        where email not like ('<EMAIL>'),
    set last_login = null
        where email not like ('<EMAIL>'),
    set date_joined = null
        where email not like ('<EMAIL>');

/*
   There are a handful of email changes requests captured in flight.
*/

UPDATE wwc.student_pendingemailchange
    set new_email = concat('success+',cast(user_id AS CHAR),'<EMAIL>');

/*
   Differs slightly to prevent creating duplicate email records. 
   User id isn't stored here and this email is probably not used for
   sending email, but cannot hurt.
*/

UPDATE wwc.student_courseenrollmentallowed
    set email = concat('success+','courseenrollmentallowed_',cast(id AS CHAR),'<EMAIL>');

/* 
  Set the name to the userid and empty the other fields
  This will also empty user profile data for edx employees
*/

UPDATE wwc.auth_userprofile
    set name = concat('user-',cast(id as CHAR)),
    set language = "",
    set location = "",
    set meta = "",
    set gender = null,
    set mailing_address = null,
    set year_of_birth = null,
    set level_of_education = null,
    set goals = null
    set country = "",
    set city = null;

/*
   Grader has its own django core tables.
*/

UPDATE prod_grader.auth_user
    set email = concat('success+',cast(id AS CHAR),'@<EMAIL>')
        where email not like ('<EMAIL>'),
    set username = concat('user-',cast(id AS CHAR))
        where email not like ('<EMAIL>'),
    set first_name = concat('user-',cast(id AS CHAR))
        where email not like ('<EMAIL>'),
    set last_name = concat('user-',cast(id AS CHAR))
        where email not like ('<EMAIL>'),
    set password = null
        where email not like ('<EMAIL>'),
    set last_login = null
        where email not like ('<EMAIL>'),
    set date_joined = null
        where email not like ('<EMAIL>');


SET FOREIGN_KEY_CHECKS=1;
<commit_msg>syntax<commit_after>SET FOREIGN_KEY_CHECKS=0;

/*
  Rewrite all emails to used the SES simulator, simulating success.
  Anonymize other user information
*/

UPDATE wwc.auth_user
    set 
        email = concat('success+',cast(id AS CHAR),'<EMAIL>'),
        username = concat('user-',cast(id AS CHAR)),
        first_name = concat('user-',cast(id AS CHAR)),
        last_name = concat('user-',cast(id AS CHAR)),
        password = <PASSWORD>,
        last_login = null,
        date_joined = null
            where email not like ('<EMAIL>');

/*
   There are a handful of email changes requests captured in flight.
*/

UPDATE wwc.student_pendingemailchange
    set new_email = concat('success+',cast(user_id AS CHAR),'<EMAIL>');

/*
   Differs slightly to prevent creating duplicate email records. 
   User id isn't stored here and this email is probably not used for
   sending email, but cannot hurt.
*/

UPDATE wwc.student_courseenrollmentallowed
    set email = concat('success+','courseenrollmentallowed_',cast(id AS CHAR),'<EMAIL>');

/* 
  Set the name to the userid and empty the other fields
  This will also empty user profile data for edx employees
*/

UPDATE wwc.auth_userprofile
    set 
        name = concat('user-',cast(id as CHAR)),
        language = "",
        location = "",
        meta = "",
        gender = null,
        mailing_address = null,
        year_of_birth = null,
        level_of_education = null,
        goals = null,
        country = "",
        city = null;

/*
   Grader has its own django core tables.
*/

UPDATE prod_grader.auth_user
    set 
        email = concat('success+',cast(id AS CHAR),'<EMAIL>'),
        username = concat('user-',cast(id AS CHAR)),
        first_name = concat('user-',cast(id AS CHAR)),
        last_name = concat('user-',cast(id AS CHAR)),
        password = <PASSWORD>,
        last_login = null,
        date_joined = null
            where email not like ('<EMAIL>');


SET FOREIGN_KEY_CHECKS=1;

{'fraction_non_alphanumeric': 0.11989100817438691, 'fraction_numerical': 0.0009082652134423251, 'mean_word_length': 2.9330357142857144, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7367191', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1347, 'n_words': 444}