<commit_before>namespace :image do
  
  desc 'for each entry main image, generate header, stream_header and dreamfield_header'   
  task :main => :environment do      
    Entry.where(:main_image_id ^ nil).each do |entry|
      image = Image.find_by_id(entry.main_image.id)
      #image = entry.main_image
      puts "processing main images for (id: #{image.id}) #{image.title}.."
      
      puts 'header'
      image.generate_profile(:header)
      puts 'stream'
      image.generate_profile(:stream_header)
      puts 'dream field header'
      image.generate_profile(:dreamfield_header)
      puts 'default thumb' 
      image.generate_profile(:thumb)
          
      thumb_sizes = %w(64 120 122)
      puts 'extra thumbs:'
      options = {}
      thumb_sizes.each do |size|
        puts size
        options[:size] = size
        image.generate_profile(:thumb,options)
      end
    end
    puts 'Done main images.'
  end
  
  desc 'for each avatar image, generate avatar_main, avatar_medium and most popular sizes (32/64)'  
  task :avatar => :environment do      
    Image.where(:title ^ 'Default Avatar',:section => 'Avatar').each do |image|
      puts "processing avatar images for (id: #{image.id}) #{image.title}.."
      
      puts 'avatar'
      image.generate_profile(:avatar)        
      puts 'avatar main'
      image.generate_profile(:avatar_main)
      puts 'avatar medium'
      image.generate_profile(:avatar_medium)
      
      extra_sizes = %w(32x32 64x64)
      puts "Resizing #{image.title}:"
      extra_sizes.each do |size|
        puts size
        # image.resize size
        image.generate_profile(:avatar, :size => size)
      end               
    end
    puts 'Done avatar images.'
  end        
    
  desc 'for each bedsheet generate a jpg'
  task :bedsheet => :environment do
    Image.where(:section => 'Bedsheets').each do |image|
      puts "processing bedsheet jpg (id: #{image.id}) #{image.title}.."
      image.generate_profile(:bedsheet, :format => 'jpg')
      puts 'default thumb' 
      image.generate_profile(:thumb, :format => 'jpg')
      puts 'thumb 120' 
      image.generate_profile(:thumb, :size => 120, :format => 'jpg')
    end
  end
    
  desc 'generate all commonly used images for main/avatar/bedsheets'
  task :generate_all_common => ['image:main','image:avatar','image:bedsheet']

  desc 'associate whats with image bank tag images'
  task :link_whats_to_tag_images => :environment do
    Image.where(section: 'Tag').each do |image|
      next if what.image_id
      pp "processing image: #{image.title}"
      what = What.for(image.title)
      what.image = image
      what.save!
    end
  end
  
end<commit_msg>minor bug fix to what tag images rake<commit_after>namespace :image do
  
  desc 'for each entry main image, generate header, stream_header and dreamfield_header'   
  task :main => :environment do      
    Entry.where(:main_image_id ^ nil).each do |entry|
      image = Image.find_by_id(entry.main_image.id)
      #image = entry.main_image
      puts "processing main images for (id: #{image.id}) #{image.title}.."
      
      puts 'header'
      image.generate_profile(:header)
      puts 'stream'
      image.generate_profile(:stream_header)
      puts 'dream field header'
      image.generate_profile(:dreamfield_header)
      puts 'default thumb' 
      image.generate_profile(:thumb)
          
      thumb_sizes = %w(64 120 122)
      puts 'extra thumbs:'
      options = {}
      thumb_sizes.each do |size|
        puts size
        options[:size] = size
        image.generate_profile(:thumb,options)
      end
    end
    puts 'Done main images.'
  end
  
  desc 'for each avatar image, generate avatar_main, avatar_medium and most popular sizes (32/64)'  
  task :avatar => :environment do      
    Image.where(:title ^ 'Default Avatar',:section => 'Avatar').each do |image|
      puts "processing avatar images for (id: #{image.id}) #{image.title}.."
      
      puts 'avatar'
      image.generate_profile(:avatar)        
      puts 'avatar main'
      image.generate_profile(:avatar_main)
      puts 'avatar medium'
      image.generate_profile(:avatar_medium)
      
      extra_sizes = %w(32x32 64x64)
      puts "Resizing #{image.title}:"
      extra_sizes.each do |size|
        puts size
        # image.resize size
        image.generate_profile(:avatar, :size => size)
      end               
    end
    puts 'Done avatar images.'
  end        
    
  desc 'for each bedsheet generate a jpg'
  task :bedsheet => :environment do
    Image.where(:section => 'Bedsheets').each do |image|
      puts "processing bedsheet jpg (id: #{image.id}) #{image.title}.."
      image.generate_profile(:bedsheet, :format => 'jpg')
      puts 'default thumb' 
      image.generate_profile(:thumb, :format => 'jpg')
      puts 'thumb 120' 
      image.generate_profile(:thumb, :size => 120, :format => 'jpg')
    end
  end
    
  desc 'generate all commonly used images for main/avatar/bedsheets'
  task :generate_all_common => ['image:main','image:avatar','image:bedsheet']

  desc 'associate whats with image bank tag images'
  task :link_whats_to_tag_images => :environment do
    Image.where(section: 'Tag').each do |image|
      pp "processing image: #{image.title}"
      what = What.for(image.title)
      next if what.image_id
      what.image = image
      what.save!
    end
  end
  
end
{'fraction_non_alphanumeric': 0.11205936920222634, 'fraction_numerical': 0.009647495361781076, 'mean_word_length': 2.6181208053691276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '4700284', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1646, 'n_words': 446}