lib/updateagent/updateagent.rb in seven1m-onebody-updateagent-0.2.2 vs lib/updateagent/updateagent.rb in seven1m-onebody-updateagent-0.2.3
- old
+ new
@@ -1,7 +1,8 @@
-MAX_HASHES_AT_A_TIME = 1000
-MAX_TO_BATCH_AT_A_TIME = 25
+MAX_HASHES_AT_A_TIME = 100
+MAX_TO_BATCH_AT_A_TIME = 10
+SLEEP_PERIOD = 5 # seconds
DEBUG = false
# general class to handle comparing and pushing data to the remote end
class UpdateAgent
@@ -122,10 +123,11 @@
statuses.select { |s| s['status'] == 'error' }.each do |status|
puts "#{status['legacy_id']}: #{status['error']}"
end
index += records.length
print "#{resource.name} #{index}/#{@create.length + @update.length}\r"; STDOUT.flush
+ sleep SLEEP_PERIOD
end
puts
end
def data_by_id
@@ -157,9 +159,10 @@
row = data_by_id[record['legacy_id'].to_i]
row['remote_hash'] = record['hash'] if DEBUG
@update << row if force or row.values_hash(@attributes) != record['hash']
end
@create += some_ids.reject { |id| hashes.map { |h| h['legacy_id'].to_i }.include?(id.to_i) }.map { |id| data_by_id[id.to_i] }
+ sleep SLEEP_PERIOD
end
puts
end
end
\ No newline at end of file