我正在编写一个Rails函数,(应该)
'/me/music'
重要的是我工作得很好。batch与我一起工作,将循环限制在前50,但我不知道如何用偏移量重新运行循环。这是我的当前循环:
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显然,@music[0..50] do |artist|不是有效的语法,所以没有运气。
发布于 2012-04-20 15:40:34
对于谷歌人来说,我就是这样解决我的问题的:
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
endhttps://stackoverflow.com/questions/10003581
复制相似问题