<commit_before>module Commands
  module Users
    class AnonymizeUserModel
      include Pavlov::Command

      attribute :user_id, String

      private

      def execute
        User.personal_information_fields.each do |field|
          user[field] = User.fields[field].default_val
        end

        user.first_name = 'Deleted'
        user.last_name  = 'user'

        user.password              = <PASSWORD>
        user.password_confirmation = <PASSWORD>

        user.username = anonymous_username
        user.email = "<EMAIL>"
        # TODO: at some point we can use an official invalid address (check RFCs)
        # For now we want to easily see what mails deleted users still get

        user.save!
      end

      def anonymous_username<commit_msg>@markijbema likes this better<commit_after>module Commands
  module Users
    class AnonymizeUserModel
      include Pavlov::Command

      attribute :user_id, String

      private

      def execute
        User.personal_information_fields.each do |field|
          user[field] = User.fields[field].default_val
        end

        user.first_name = 'Deleted'
        user.last_name  = 'User'

        user.password              = <PASSWORD>
        user.password_confirmation = <PASSWORD>

        user.username = anonymous_username
        user.email = "<EMAIL>"
        # TODO: at some point we can use an official invalid address (check RFCs)
        # For now we want to easily see what mails deleted users still get

        user.save!
      end

      def anonymous_username
{'fraction_non_alphanumeric': 0.06387096774193549, 'fraction_numerical': 0.0, 'mean_word_length': 2.1653061224489796, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6437748', 'n_tokens_mistral': 421, 'n_tokens_neox': 405, 'n_words': 126}