我正在尝试将评论从大约2000个项目迁移到另一个应用程序中。我知道过滤器有500个记录的限制。我传递的偏移量就像文档中所说的那样:
https://developers.podio.com/doc/items/filter-items-4496747
以下是代码:
$collection = PodioItem::filter(config('podio.content_app_id'),[
'limit' => 500,
'offset' => $offset,
'sort_by' => 'created_on',
'sort_desc' => true
]);
while循环中的偏移量发生变化,我知道它正在递增。
我从1200收集的应用程序,但我提出的每个请求有500条记录,它们几乎相同(这很奇怪)。
我使用增量偏移量制作了5个请求,我只获得了504个唯一的项目ID。我错过了什么吗?
谢谢,
波多黎各
答案 0 :(得分:0)
这就是我在 Ruby
中做到这一点的方式options = {'limit' => 100, 'offset' => 0}
filter = {:last_edit_on => {:from => '-7d', :to => '+0d'}} # as example, work with most recent items only
all_found_items = []
result = Podio::Item.find_by_filter_values(app_id, filter, options)
puts "Found #{result.count} items matching filter #{filter}"
all_found_items += result.all
while all_found_items.length < result.count
options['offset'] = all_found_items.length
result = Podio::Item.find_by_filter_values(app.app_id, filter, options)
all_found_items += result.all
end
all_found_items.each_with_index do |item, i|
puts "\t#{i+1}: #{item.title}"
end
当我拿走了数以千计的物品时,效果很好。