Changeset 2194

Show
Ignore:
Timestamp:
06/22/09 12:53:43 (1 year ago)
Author:
kindlund
Message:

Updated data migration script.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hive/trunk/data_webapp/lib/tasks/collector.rake

    r2125 r2194  
    2323  end 
    2424 
     25  # Given millis from the Epoch convert it to 
     26  # the String version of a Date 
     27  def _microseconds_to_string(value) 
     28    return value unless value.is_a?(BigDecimal) 
     29    f = value.to_s 
     30    a = f.split(".") 
     31    t = Time.at(a[0].to_f) 
     32    t.strftime("%Y-%m-%d %H:%M:%S.#{a[1]} %Z") 
     33  end 
     34  private :_microseconds_to_string 
     35 
    2536  # Gets all nested attributes that correspond to foreign keys in this object. 
    2637  def _get_nested_attributes(object) 
     
    6273 
    6374          # Clean up the client timestamps. 
    64           data[key]["created_at"] = microseconds_to_string(BigDecimal.new(data[key]["start"].to_s)) 
     75          data[key]["created_at"] = _microseconds_to_string(BigDecimal.new(data[key]["start"].to_s)) 
    6576          data[key].delete("start") 
    6677          if (!data[key]["compromise"].nil?) 
    67             data[key]["suspended_at"] = microseconds_to_string(BigDecimal.new(data[key]["compromise"].to_s)) 
     78            data[key]["suspended_at"] = _microseconds_to_string(BigDecimal.new(data[key]["compromise"].to_s)) 
    6879          end 
    6980          data[key].delete("compromise") 
     
    236247 
    237248    messages = [] 
    238     offset = 3 
     249    offset = 0 
    239250    #offset = 0 
    240251    #limit = 1000 
     
    243254    print "\n" 
    244255    STDOUT.flush 
    245     while (objects.size > 0) && (offset < 4) do 
     256    while (objects.size > 0) do 
    246257      print objects.first.id.to_s + ".." 
    247258      STDOUT.flush 
     
    321332    # Get a list of all compromised clients. 
    322333    clients = Client.find(:all, :conditions => {:status => "compromised"}) 
    323     client = clients[63] 
    324334    clients.each do |client| 
    325335      print client.id.to_s + ".."