<commit_before>class Post < ActiveRecord::Base
  belongs_to :user
  has_attached_file :avatar, 
   :path =>"/avatars/:id/:style/:basename.:extension", :default_url => "/images/cat3.gif",
   :storage => :s3,
       :bucket => 'catsinyourhats',
       :s3_credentials => {
         :access_key_id => ENV['S3_KEY'],
         :secret_access_key => ENV['S3_SECRET']
       }
  
  def self.updatepost(post)
    require 'RMagick'
    include Magick
   
   
    @post=post
    

    #images. All images must be different files 
     #background image
  #   back= "#{RAILS_ROOT}/public/images/catsback.png"
      back= @post.backimg
      
     #cat images
     cat1= "#{RAILS_ROOT}/public/images/cat1.gif"
     cat2= "#{RAILS_ROOT}/public/images/cat2.gif"
     cat3= "#{RAILS_ROOT}/public/images/cat3.gif"
     cat4= "#{RAILS_ROOT}/public/images/cat4.gif"
     cat5= "#{RAILS_ROOT}/public/images/cat5.gif"
     cat6= "#{RAILS_ROOT}/public/images/cat6.gif"

     #hat images
     hat1= "#{RAILS_ROOT}/public/images/hat1.gif"
     hat2= "#{RAILS_ROOT}/public/images/hat2.gif"
     hat3= "#{RAILS_ROOT}/public/images/hat3.gif"
     hat4= "#{RAILS_ROOT}/public/images/hat4.gif"
     hat5= "#{RAILS_ROOT}/public/images/hat5.gif"
     hat6= "#{RAILS_ROOT}/public/images/hat6.gif"


      #Array of all images
     img_all=ImageList.new(back, cat1, cat2, cat3, cat4, cat5, cat6, hat1, hat2, hat3, hat4, hat5, hat6)


     #Array giving index of img_all which were moved
     moved=[@post.cat1move, @post.cat2move, @post.cat3move, @post.cat4move, @post.cat5move, @post.cat6move, @post.hat1move, @post.hat2move, @post.hat3move, @post.hat4move, @post.hat5move, @post.hat6move]


    # Dimension is the square dimension of each image 
     dimension_cat1= (@post.cat1h) > (@post.cat1w)?(@post.cat1h):(@post.cat1w)
     img_all[1]=img_all[1].resize_to_fit(dimension_cat1,dimension_cat1)
     img_all[1].page=Rectangle.new(@post.cat1h, @post.cat1w, @post.cat1x, (@post.cat1y)-(@post.backy))
     # 80 is subtracted to get the y co-ordinate wrt back image. Cat1y is wrt top left of page

     # Repeating for cat2
     dimension_cat2= (@post.cat2h) > (@post.cat2w)?(@post.cat2h):(@post.cat2w)
      img_all[2]=img_all[2].resize_to_fit(dimension_cat2,dimension_cat2)
      img_all[2].page=Rectangle.new(@post.cat2h, @post.cat2w, @post.cat2x, (@post.cat2y)-(@post.backy))

     #Repeating for cat3
     dimension_cat3= (@post.cat3h) > (@post.cat3w)?(@post.cat3h):(@post.cat3w)
        img_all[3]=img_all[3].resize_to_fit(dimension_cat3,dimension_cat3)
        img_all[3].page=Rectangle.new(@post.cat3h, @post.cat3w, @post.cat3x, (@post.cat3y)-(@post.backy))

       #Repeating for cat4 
        dimension_cat4= (@post.cat4h) > (@post.cat4w)?(@post.cat4h):(@post.cat4w)
        img_all[4]=img_all[4].resize_to_fit(dimension_cat4,dimension_cat4)
        img_all[4].page=Rectangle.new(@post.cat4h, @post.cat4w, @post.cat4x, (@post.cat4y)-(@post.backy))
        # 80 is subtracted to get the y co-ordinate wrt back image. Cat1y is wrt top left of page

        # Repeating for cat5
        dimension_cat5= (@post.cat5h) > (@post.cat5w)?(@post.cat5h):(@post.cat5w)
         img_all[5]=img_all[5].resize_to_fit(dimension_cat5,dimension_cat5)
         img_all[5].page=Rectangle.new(@post.cat5h, @post.cat5w, @post.cat5x, (@post.cat5y)-(@post.backy))

        #Repeating for cat3
        dimension_cat6= (@post.cat6h) > (@post.cat6w)?(@post.cat6h):(@post.cat6w)
           img_all[6]=img_all[6].resize_to_fit(dimension_cat6,dimension_cat6)
           img_all[6].page=Rectangle.new(@post.cat6h, @post.cat6w, @post.cat6x, (@post.cat6y)-(@post.backy))


     # When adding more cats or hats, change the image number index
    # Dimension is the square dimensaion of each image . Hat1 first
         dimension_hat1= (@post.hat1h) > (@post.hat1w)?(@post.hat1h):(@post.hat1w)
         img_all[7]=img_all[7].resize_to_fit(dimension_hat1,dimension_hat1)
         img_all[7].page=Rectangle.new(@post.hat1h, @post.hat1w, (@post.hat1x)-(@post.backx), (@post.hat1y)-(@post.backy))
    # 80 is subtracted to get the y co-ordinate wrt back image. Cat1y is wrt top left of page

         # Repeating for hat2
         dimension_hat2= (@post.hat2h) > (@post.hat2w)?(@post.hat2h):(@post.hat2w)
          img_all[8]=img_all[8].resize_to_fit(dimension_hat2,dimension_hat2)
          img_all[8].page=Rectangle.new(@post.hat2h, @post.hat2w, (@post.hat2x)-(@post.backx), (@post.hat2y)-(@post.backy))

         #Repeating for hat3
         dimension_hat3= (@post.hat3h) > (@post.hat3w)?(@post.hat3h):(@post.hat3w)<commit_msg>corrected cat co-ordinates<commit_after>class Post < ActiveRecord::Base
  belongs_to :user
  has_attached_file :avatar, 
   :path =>"/avatars/:id/:style/:basename.:extension", :default_url => "/images/cat3.gif",
   :storage => :s3,
       :bucket => 'catsinyourhats',
       :s3_credentials => {
         :access_key_id => ENV['S3_KEY'],
         :secret_access_key => ENV['S3_SECRET']
       }
  
  def self.updatepost(post)
    require 'RMagick'
    include Magick
   
   
    @post=post
    

    #images. All images must be different files 
     #background image
  #   back= "#{RAILS_ROOT}/public/images/catsback.png"
      back= @post.backimg
      
     #cat images
     cat1= "#{RAILS_ROOT}/public/images/cat1.gif"
     cat2= "#{RAILS_ROOT}/public/images/cat2.gif"
     cat3= "#{RAILS_ROOT}/public/images/cat3.gif"
     cat4= "#{RAILS_ROOT}/public/images/cat4.gif"
     cat5= "#{RAILS_ROOT}/public/images/cat5.gif"
     cat6= "#{RAILS_ROOT}/public/images/cat6.gif"

     #hat images
     hat1= "#{RAILS_ROOT}/public/images/hat1.gif"
     hat2= "#{RAILS_ROOT}/public/images/hat2.gif"
     hat3= "#{RAILS_ROOT}/public/images/hat3.gif"
     hat4= "#{RAILS_ROOT}/public/images/hat4.gif"
     hat5= "#{RAILS_ROOT}/public/images/hat5.gif"
     hat6= "#{RAILS_ROOT}/public/images/hat6.gif"


      #Array of all images
     img_all=ImageList.new(back, cat1, cat2, cat3, cat4, cat5, cat6, hat1, hat2, hat3, hat4, hat5, hat6)


     #Array giving index of img_all which were moved
     moved=[@post.cat1move, @post.cat2move, @post.cat3move, @post.cat4move, @post.cat5move, @post.cat6move, @post.hat1move, @post.hat2move, @post.hat3move, @post.hat4move, @post.hat5move, @post.hat6move]


    # Dimension is the square dimension of each image 
     dimension_cat1= (@post.cat1h) > (@post.cat1w)?(@post.cat1h):(@post.cat1w)
     img_all[1]=img_all[1].resize_to_fit(dimension_cat1,dimension_cat1)
     img_all[1].page=Rectangle.new(@post.cat1h, @post.cat1w, (@post.cat1x)-(@post.backx), (@post.cat1y)-(@post.backy))
     # 80 is subtracted to get the y co-ordinate wrt back image. Cat1y is wrt top left of page

     # Repeating for cat2
     dimension_cat2= (@post.cat2h) > (@post.cat2w)?(@post.cat2h):(@post.cat2w)
      img_all[2]=img_all[2].resize_to_fit(dimension_cat2,dimension_cat2)
      img_all[2].page=Rectangle.new(@post.cat2h, @post.cat2w, (@post.cat2x)-(@post.backx), (@post.cat2y)-(@post.backy))

     #Repeating for cat3
     dimension_cat3= (@post.cat3h) > (@post.cat3w)?(@post.cat3h):(@post.cat3w)
        img_all[3]=img_all[3].resize_to_fit(dimension_cat3,dimension_cat3)
        img_all[3].page=Rectangle.new(@post.cat3h, @post.cat3w, (@post.cat3x)-(@post.backx), (@post.cat3y)-(@post.backy))

       #Repeating for cat4 
        dimension_cat4= (@post.cat4h) > (@post.cat4w)?(@post.cat4h):(@post.cat4w)
        img_all[4]=img_all[4].resize_to_fit(dimension_cat4,dimension_cat4)
        img_all[4].page=Rectangle.new(@post.cat4h, @post.cat4w, (@post.cat4x)-(@post.backx), (@post.cat4y)-(@post.backy))
        # 80 is subtracted to get the y co-ordinate wrt back image. Cat1y is wrt top left of page

        # Repeating for cat5
        dimension_cat5= (@post.cat5h) > (@post.cat5w)?(@post.cat5h):(@post.cat5w)
         img_all[5]=img_all[5].resize_to_fit(dimension_cat5,dimension_cat5)
         img_all[5].page=Rectangle.new(@post.cat5h, @post.cat5w, (@post.cat5x)-(@post.backx), (@post.cat5y)-(@post.backy))

        #Repeating for cat3
        dimension_cat6= (@post.cat6h) > (@post.cat6w)?(@post.cat6h):(@post.cat6w)
           img_all[6]=img_all[6].resize_to_fit(dimension_cat6,dimension_cat6)
           img_all[6].page=Rectangle.new(@post.cat6h, @post.cat6w, (@post.cat6x)-(@post.backx), (@post.cat6y)-(@post.backy))


     # When adding more cats or hats, change the image number index
    # Dimension is the square dimensaion of each image . Hat1 first
         dimension_hat1= (@post.hat1h) > (@post.hat1w)?(@post.hat1h):(@post.hat1w)
         img_all[7]=img_all[7].resize_to_fit(dimension_hat1,dimension_hat1)
         img_all[7].page=Rectangle.new(@post.hat1h, @post.hat1w, (@post.hat1x)-(@post.backx), (@post.hat1y)-(@post.backy))
    # 80 is subtracted to get the y co-ordinate wrt back image. Cat1y is wrt top left of page

         # Repeating for hat2
         dimension_hat2= (@post.hat2h) > (@post.hat2w)?(@post.hat2h):(@post.hat2w)
          img_all[8]=img_all[8].resize_to_fit(dimension_hat2,dimension_hat2)
          img_all[8].page=Rectangle.new(@post.hat2h, @post.hat2w, (@post.hat2x)-(@post.backx), (@post.hat2y)-(@post.backy))

         #Repeating for hat3
         dimension_hat3= (@post.hat3h) > (@post.hat3w)?(@post.hat3h):(@post.hat3w)
{'fraction_non_alphanumeric': 0.16747756514217754, 'fraction_numerical': 0.04043680397880852, 'mean_word_length': 3.6111665004985043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '4181466', 'n_tokens_mistral': 3770, 'n_tokens_neox': 3648, 'n_words': 553}