@@ -42,26 +42,35 @@ use Sub::Exporter -setup => {
4242 is_bool
4343 to_bool
4444 MAX_RESULT_WINDOW
45+ MAX_FAVORITE_RESULT_WINDOW
4546 MAX_PAGE_SIZE
47+ MAX_FAVORITE_PAGE_SIZE
4648 paginate
4749 ) ]
4850};
4951
50- # Limit the maximum result window to 1000, really should be enough!
52+ # Must not exceed the ES index.max_result_window setting (default 10,000).
5153use constant MAX_RESULT_WINDOW => 1000;
52- use constant MAX_PAGE_SIZE => 250;
54+
55+ # The UI's list_as_json needs a complete set of user favorites, so the default
56+ # of 250 will not be enough for heavy users of the ++ button.
57+ use constant MAX_FAVORITE_RESULT_WINDOW => 5000;
58+ use constant MAX_PAGE_SIZE => 250;
59+ use constant MAX_FAVORITE_PAGE_SIZE => 2000;
5360
5461# Returns ($page, $size, $from) or empty list if the request exceeds
55- # the ES result window. Use strict ">" so that page*size == MAX_RESULT_WINDOW
56- # (e.g. page 4 × 250 = 1000) is still valid — ES allows from+size ≤ window.
62+ # the configured result window. Use strict ">" so that page*size equal to
63+ # the window (e.g. page 4 × 250 = 1000) is still valid — ES allows from+size ≤ window.
5764sub paginate {
58- my ( $page , $size ) = @_ ;
65+ my ( $page , $size , $max_result_window , $max_page_size ) = @_ ;
66+ $max_result_window //= MAX_RESULT_WINDOW;
67+ $max_page_size //= MAX_PAGE_SIZE;
5968 $page = Int-> check($page ) ? max( 1, $page ) : 1;
6069 $size
6170 = Int-> check($size ) && $size >= 1
62- ? min( MAX_PAGE_SIZE , $size )
63- : MAX_PAGE_SIZE ;
64- return if $page * $size > MAX_RESULT_WINDOW ;
71+ ? min( $max_page_size , $size )
72+ : $max_page_size ;
73+ return if $page * $size > $max_result_window ;
6574 return ( $page , $size , ( $page - 1 ) * $size );
6675}
6776
0 commit comments