canvas::API method paginated_result_list (protected)

 <instance of canvas::API[i]> paginated_result_list \
    [ -max_entries max_entries ] r expected_status_code

Defined in packages/xooauth/tcl/canvas-procs.tcl

By default, Canvas returns for a query just the first 10 results ("pagination"). To obtain more results, it is necessary to issue multiple requests. If "max_entries" is specified, the interface tries to get the requested number of entries. If there are less entries available, just these are returned.

Switches:
-max_entries (optional)
Parameters:
r (required)
expected_status_code (required)

Testcases:
No testcase defined.
Source code:
set resultList [:expect_status_code $r $expected_status_code]
if {$max_entries ne ""} {
    while {1} {
        set got [llength $resultList]
        ns_log notice "[self] paginated_result_list: got $got max_entries $max_entries"
        if {$got >= $max_entries} {
            set resultList [lrange $resultList 0 $max_entries-1]
            break
        }
        if {[dict exists $r link] && [dict exists [dict get $r link] next]} {
            set r [:request -method GET -token ${:token}  -url [dict get [dict get $r link] next]]
            lappend resultList {*}[:expect_status_code $r 200]
        } else {
            #ns_log notice "=== No next link"
            break
        }
    }
}
return $resultList
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: