<commit_before>namespace :one_off do
  desc "Alert users who've saved at least one tree"
  task trees_notification: :environment do
    User.find_each do |user|
      trees = GreenService.total_trees_saved_by(user)
    
      if trees >= 1
        user = User.first
        user.notifications.create!(
          message_html: "<div>You've saved #{trees.round} tree#{'s' if trees.round > 1} by going digital!</div><div class='blue-text text-darken-3'>That's AWESOME! Click here to see how.</div>",
          icon:         'park',
          icon_color:   'green',
          happened_at:  DateTime.current,
          passthrough_link: 'https://www.notebook.ai/my/data/green',
          reference_code: 'green-trees'
        ) unless user.notifications.where(reference_code: 'green-trees').any?
      end
    end
  end
  
  desc "Create a notification for all users telling them about the new notifications"
  task notifications_announcement: :environment do
    User.all.find_each do |user|
      user.notifications.create(
        message_html: '<div>A new feature is now available:</div><div class="blue-text text-darken-3">Notifications on Notebook.ai</div>',
        icon:         'favorite',
        icon_color:   'red',
        happened_at:  DateTime.current,
        passthrough_link: 'https://medium.com/indent-labs/notifications-on-notebook-ai-693544b676cb'
      )
    end
  end<commit_msg>ref code<commit_after>namespace :one_off do
  desc "Alert users who've saved at least one tree"
  task trees_notification: :environment do
    reference_code = 'green-trees'

    User.find_each do |user|
      trees = GreenService.total_trees_saved_by(user)
    
      if trees >= 1
        user = User.first
        user.notifications.create!(
          message_html: "<div>You've saved #{trees.round} tree#{'s' if trees.round > 1} by going digital!</div><div class='blue-text text-darken-3'>That's AWESOME! Click here to see how.</div>",
          icon:         'park',
          icon_color:   'green',
          happened_at:  DateTime.current,
          passthrough_link: 'https://www.notebook.ai/my/data/green',
          reference_code: reference_code
        ) unless user.notifications.where(reference_code: reference_code).any?
      end
    end
  end
  
  desc "Create a notification for all users telling them about the new notifications"
  task notifications_announcement: :environment do
    User.all.find_each do |user|
      user.notifications.create(
        message_html: '<div>A new feature is now available:</div><div class="blue-text text-darken-3">Notifications on Notebook.ai</div>',
        icon:         'favorite',
        icon_color:   'red',
        happened_at:  DateTime.current,
        passthrough_link: 'https://medium.com/indent-labs/notifications-on-notebook-ai-693544b676cb'
      )
    end
  end
{'fraction_non_alphanumeric': 0.11036434382737885, 'fraction_numerical': 0.00919702865228157, 'mean_word_length': 2.7959731543624162, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '3062691', 'n_tokens_mistral': 886, 'n_tokens_neox': 855, 'n_words': 210}