【问题标题】:Podio Api filter offset doesn't seem to be workingPodio Api 过滤器偏移似乎不起作用
【发布时间】:2017-07-17 08:20:20
【问题描述】:

我正在尝试将 cmets 从大约 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。我错过了什么吗?

谢谢,

里科

【问题讨论】:

    标签: podio


    【解决方案1】:

    这就是我在 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
    

    当我提取了数千件物品时效果很好。

    【讨论】:

    • php api 显示调用如下: PodioItem::filter( $app_id, $attributes = array(), $options = array() ); 什么是属性选项是什么?也许这是我的问题
    • 您是否尝试过使用 $options 存储限制和偏移量以及使用 $attributes 存储过滤器值?
    猜你喜欢
    • 2015-09-28
    • 2012-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    相关资源
    最近更新 更多