I'm writing a Rails function that (should)
Import I've got working just fine. And batch works with me restricting the loop to the first 50, but I'm not sure how to rerun the loop with an offset. This is my current loop:
Koala::Facebook::BatchOperation.instance_variable_set(:@identifier, 0)
results = @graph.batch do |batch_api|
@music.each do |artist|
if(i == 50)
break
end
batch_api.get_object(artist["id"])
i=i+1
end
end
Apparently @music[0..50] do |artist|
is not valid syntax, so no luck there.
For googlers, this is how I solved my problem:
artist_ids = music.each do |artist|
artist["id"]
end
Koala::Facebook::BatchOperation.instance_variable_set(:@identifier, 0)
artist_ids.in_groups_of(50) do |artists|
i=0
results = graph.batch do |batch_api|
for artist in artists do
# ((Your code))
i=i+1
end
end
results.each do |artist|
# ((Your code))
end
end