<commit_before>namespace :db do
  desc 'Housekeeping for obsolete DB records'
  task cleanup: :environment do
    puts "Rake db:cleanup start at: #{Time.now}"

    #Notification.where('created_at < ?', 2.weeks.ago).destroy_all
    #Notification.where('created_at < ?', 2.weeks.ago).where(notify_before: nil).destroy_all
    #Notification.where('created_at < ?', 2.weeks.ago).where.not("notify_before >= CURRENT_DATE").destroy_all
    Notification.where('notify_at < ?', 3.weeks.ago).where("notify_before IS NULL OR notify_before < ?", Time.current).destroy_all

    # Delete WeLocally Activities after 6 Months and Vienna Activities after 8 Weeks
    Activity.where('created_at < ?', 6.months.ago).destroy_all
    Activity.where('region_id = ?', 'wien').where('created_at < ?', 8.weeks.ago).destroy_all

    Activity.where(subject_type: 'Meeting').find_each do |activity|
      if activity.subject.ends_at_date
        activity.destroy if activity.subject.ends_at_date < Date.yesterday
      else
        activity.destroy if activity.subject.starts_at_date < Date.yesterday
      end
    end
<commit_msg>small improve fpr cleanup task<commit_after>namespace :db do
  desc 'Housekeeping for obsolete DB records'
  task cleanup: :environment do
    puts "Rake db:cleanup start at: #{Time.now}"

    # Delete Expired and already sent Notifications
    Notification.where('notify_at < ?', 3.weeks.ago).where("notify_before IS NULL OR notify_before < ?", Time.current).destroy_all
    Notification.where('notify_at < ?', 3.weeks.ago).where(sent: true).destroy_all

    # Delete WeLocally Activities after 6 Months and Vienna Activities after 8 Weeks
    Activity.where('created_at < ?', 6.months.ago).destroy_all
    Activity.where('region_id = ?', 'wien').where('created_at < ?', 8.weeks.ago).destroy_all

    Activity.where(subject_type: 'Meeting').find_each do |activity|
      if activity.subject.ends_at_date
        activity.destroy if activity.subject.ends_at_date < Date.yesterday
      else
        activity.destroy if activity.subject.starts_at_date < Date.yesterday
      end
    end

{'fraction_non_alphanumeric': 0.11674641148325358, 'fraction_numerical': 0.0066985645933014355, 'mean_word_length': 4.075242718446602, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 4, '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': '781929', 'n_tokens_mistral': 665, 'n_tokens_neox': 624, 'n_words': 141}