<commit_before>require 'uri'
require 'rentjuicer'
require 'listing_title'

def in_memory_file(data, pathname)
  #load up some data
  file = StringIO.new(data)

  #tell the class that it knows about a "name" property,
  #and assign the filename to it
  file.class.class_eval { attr_accessor :original_filename } 
  file.original_filename = pathname 
  
  file.class.class_eval { attr_accessor :content_type } 
  file.content_type = "image/#{pathname.split(".").last }"

  #FPDF uses the rindex and [] funtions on the "filename",
  #so we'll make our in-memory file object act like a filename
  #with respect to these functions:
  def file.rindex arg 
    name.rindex arg 
  end 

  #this same pattern could be used to add other metadata
  #to the file (e.g., creation time)
  def file.[] arg 
    name[arg] 
  end  

  #change open so that it follows the formal behavior
  #of the original (call a block with data, return
  #the file-like object, etc.) but alter it so that
  #it doesn't create a new instance and can be
  #called multiple times (rewind)
  def file.open(*mode, &block) 
    self.rewind 
    block.call(self) if block 
    return self 
  end 

  return file 
end

namespace :rentjuicer do
  desc "Import from RentJuicer"
  task :import => :environment do
    @running = true
    Kernel.trap("INT"){
      @running = false
      print " *****************************\n"
      print " * Gracefully killing import *\n"
      print " *****************************\n"
    }

    kanga_neighborhoods = [
    "Boynton Beach", "Boca Raton", "Coconut Creek", "Coral Springs", "Deerfield Beach", 
    "Delray Beach", "Jupiter", "Lake Park", "Lake Worth", "Palm Beach", "Palm Beach Gardens", 
    "North Palm Beach", "Royal Palm Beach", "Stuart", "Tequesta", "Wellington", "West Palm Beach"] * ", "
    kanga = [{:min_rent => 850, :max_rent => 1500, :has_photos => 1, :include_mls => 1, :featured => 1}]

    casa_neighborhoods = ["Boca Raton", "Deerfield Beach", "Delray Beach", "Highland Beach", "Hillsboro Beach", "Parkland"]

    maf = [
    {:min_beds => 1, :max_beds => 1, :min_rent => 1800, :max_rent => 2500, :has_photos => 1, :include_mls => 1},
    {:min_beds => 2, :max_beds => 2, :min_rent => 2000, :max_rent => 5000, :has_photos => 1, :include_mls => 1}
    ]
    elizabeth_neighborhoods = ["Miami Beach", "Brickell"] * ", " #"Surfside",  
    paola_neighborhoods     = [               "Brickell", "Coral Gables", "Coconut Grove", "Downtown Miami"] * ", "
    ronda_neighborhoods     = ["Miami Beach", "North Beach", "Bay Harbour"] * ", "

    customers = [
    {:name => 'maf_elizabeth',
    :rj_id => '868f2445f9f09786e35f8a1b9356a417',
    :hoods => {:neighborhoods => elizabeth_neighborhoods},
    :filter => maf,
    :email => {:agent => "<EMAIL>"}
    },

    {:name => 'maf_ronda',
    :rj_id => '868f2445f9f09786e35f8a1b9356a417',
    :hoods => {:neighborhoods => ronda_neighborhoods},
    :filter => maf,
    :email => {:agent => "ron<EMAIL>"}
    },

    {:name => 'maf_paola',
    :rj_id => '868f2445f9f09786e35f8a1b9356a417',
    :hoods => {:neighborhoods => paola_neighborhoods},
    :filter => maf,
    :email => {:agent => "<EMAIL>"}
    },

    {:name => 'kangarent',
    :rj_id => '3b97f4ec544152dd3a79ca0c19b32aab',
    :hoods => {:neighborhoods => kanga_neighborhoods},
    :filter => kanga,
    :email => {:agent => "<EMAIL>"},
    :location => Location.find_by_url("miami"),
    :sublocation => Sublocation.find_by_url("pbc")
    },

    {:name => 'casabellaboca',
    :rj_id => 'e18a66e3f23c9d65e53072fcf0560542',
    :hoods => {:neighborhoods => casa_neighborhoods},
    :filter => [{:include_mls => 1, :featured => 1}],
    :email => {:agent => "<EMAIL>"},
    :location => Location.find_by_url("miami"),
    :sublocation => Sublocation.find_by_url("pbc")
    }
    ]

    @connections = {}<commit_msg>The old customers were missing their locations<commit_after>require 'uri'
require 'rentjuicer'
require 'listing_title'

def in_memory_file(data, pathname)
  #load up some data
  file = StringIO.new(data)

  #tell the class that it knows about a "name" property,
  #and assign the filename to it
  file.class.class_eval { attr_accessor :original_filename } 
  file.original_filename = pathname 
  
  file.class.class_eval { attr_accessor :content_type } 
  file.content_type = "image/#{pathname.split(".").last }"

  #FPDF uses the rindex and [] funtions on the "filename",
  #so we'll make our in-memory file object act like a filename
  #with respect to these functions:
  def file.rindex arg 
    name.rindex arg 
  end 

  #this same pattern could be used to add other metadata
  #to the file (e.g., creation time)
  def file.[] arg 
    name[arg] 
  end  

  #change open so that it follows the formal behavior
  #of the original (call a block with data, return
  #the file-like object, etc.) but alter it so that
  #it doesn't create a new instance and can be
  #called multiple times (rewind)
  def file.open(*mode, &block) 
    self.rewind 
    block.call(self) if block 
    return self 
  end 

  return file 
end

namespace :rentjuicer do
  desc "Import from RentJuicer"
  task :import => :environment do
    @running = true
    Kernel.trap("INT"){
      @running = false
      print " *****************************\n"
      print " * Gracefully killing import *\n"
      print " *****************************\n"
    }

    kanga_neighborhoods = [
    "Boynton Beach", "Boca Raton", "Coconut Creek", "Coral Springs", "Deerfield Beach", 
    "Delray Beach", "Jupiter", "Lake Park", "Lake Worth", "Palm Beach", "Palm Beach Gardens", 
    "North Palm Beach", "Royal Palm Beach", "Stuart", "Tequesta", "Wellington", "West Palm Beach"] * ", "
    kanga = [{:min_rent => 850, :max_rent => 1500, :has_photos => 1, :include_mls => 1, :featured => 1}]

    casa_neighborhoods = ["Boca Raton", "Deerfield Beach", "Delray Beach", "Highland Beach", "Hillsboro Beach", "Parkland"]

    maf = [
    {:min_beds => 1, :max_beds => 1, :min_rent => 1800, :max_rent => 2500, :has_photos => 1, :include_mls => 1},
    {:min_beds => 2, :max_beds => 2, :min_rent => 2000, :max_rent => 5000, :has_photos => 1, :include_mls => 1}
    ]
    elizabeth_neighborhoods = ["Miami Beach", "Brickell"] * ", " #"Surfside",  
    paola_neighborhoods     = [               "Brickell", "Coral Gables", "Coconut Grove", "Downtown Miami"] * ", "
    ronda_neighborhoods     = ["Miami Beach", "North Beach", "Bay Harbour"] * ", "

    customers = [
    {:name => 'maf_elizabeth',
    :rj_id => '868f2445f9f09786e35f8a1b9356a417',
    :hoods => {:neighborhoods => elizabeth_neighborhoods},
    :filter => maf,
    :email => {:agent => "<EMAIL>"},
    :location => Location.find_by_url("miami"),
    :sublocation => Sublocation.find_by_url("mdc")
    },

    {:name => 'maf_ronda',
    :rj_id => '868f2445f9f09786e35f8a1b9356a417',
    :hoods => {:neighborhoods => ronda_neighborhoods},
    :filter => maf,
    :email => {:agent => "<EMAIL>"},
    :location => Location.find_by_url("miami"),
    :sublocation => Sublocation.find_by_url("mdc")
    },

    {:name => 'maf_paola',
    :rj_id => '868f2445f9f09786e35f8a1b9356a417',
    :hoods => {:neighborhoods => paola_neighborhoods},
    :filter => maf,
    :email => {:agent => "<EMAIL>"},
    :location => Location.find_by_url("miami"),
    :sublocation => Sublocation.find_by_url("mdc")
    },

    {:name => 'kangarent',
    :rj_id => '3b97f4ec544152dd3a79ca0c19b32aab',
    :hoods => {:neighborhoods => kanga_neighborhoods},
    :filter => kanga,
    :email => {:agent => "<EMAIL>"},
    :location => Location.find_by_url("miami"),
    :sublocation => Sublocation.find_by_url("pbc")
    },

    {:name => 'casabellaboca',
    :rj_id => 'e18a66e3f23c9d65e53072fcf0560542',
    :hoods => {:neighborhoods => casa_neighborhoods},
    :filter => [{:include_mls => 1, :featured => 1}],
    :email => {:agent => "<EMAIL>"},
    :location => Location.find_by_url("miami"),
    :sublocation => Sublocation.find_by_url("pbc")
    }
    ]

    @connections = {}
{'fraction_non_alphanumeric': 0.16691616766467066, 'fraction_numerical': 0.036926147704590816, 'mean_word_length': 3.542209631728045, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 137, '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': '205248', 'n_tokens_mistral': 3165, 'n_tokens_neox': 2840, 'n_words': 712}