lib/flydata/api/data_entry.rb in flydata-0.7.11 vs lib/flydata/api/data_entry.rb in flydata-0.7.12
- old
+ new
@@ -40,11 +40,11 @@
# },
# "message": "",
# "success": true
# }
- NUM_TABLES_PER_REQUEST = 110
+ NUM_TABLES_PER_REQUEST = 50
def buffer_stat(data_entry_id, options = {})
table_array = options[:tables] || ['']
table_array = [''] if table_array.empty?
results = []
@@ -178,11 +178,15 @@
# }
# }
# - If value is nil, the setting will be deleted.
# - If table's attribute hash doesn't have an attribute key, the setting for the attribute for the table will not be changed
def update_table_validity(data_entry_id, table_update_hash)
- @client.post("/#{@model_name.pluralize}/#{data_entry_id}/update_table_validity", {:headers => {:content_type => :json}}, table_update_hash.to_json)
+ slice_hash(table_update_hash[:updated_tables], NUM_TABLES_PER_REQUEST).each do |table_update_hash_sl|
+ # re-construct sliced argument hash
+ arg_hash = {updated_tables: table_update_hash_sl}
+ @client.post("/#{@model_name.pluralize}/#{data_entry_id}/update_table_validity", {:headers => {:content_type => :json}}, arg_hash.to_json)
+ end
end
# Tells the server that an initial sync has completed
# stats_hash: {"init_sync_stats":{"Table1": 100, "Table2": 12345}}
# Sent 100 records for Table1, Sent 12345 records for Table2
@@ -207,9 +211,16 @@
else
message = " -> Calculating remaining bytes..."
end
message
+ end
+
+ # return Array of Hash, sliced in length
+ def slice_hash(original_hash, length)
+ original_hash.each_slice(length).collect do |sl|
+ sl.inject({}) { |h, (k,v)| h[k] = v; h }
+ end
end
end
end
end