-
Couldn't load subscription status.
- Fork 26
Implemented marker-based pagination in box_ls
#79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Merging recent changes from original repo
…ing offset-based paging methods. User can now set which one, but marker is the default.
# Conflicts: # R/boxr_misc.R # man/box_ls.Rd
|
Hi Alec, I appreciate this PR. Unfortunately it may be a few days before I will have time to look at it properly. Ian |
|
Certainly, take your time! I will let you know if I encounter any issues within my fork. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Alec,
Thanks for putting this together - I have a few ideas to make things a bit cleaner.
Unless you have a reason to preserve offset-based pagination, I would redo this by converting box_pagination() to use markers, and dropping support for offsets.
Thanks!
DESCRIPTION
Outdated
| Type: Package | ||
| Title: Interface for the 'Box.com API' | ||
| Version: 0.3.4.99999 | ||
| Version: 0.3.4.999999 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave the version number the same, for the time-being.
R/boxr_misc.R
Outdated
|
|
||
| out = list() | ||
|
|
||
| url$query$usemarker = T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use TRUE instead of T
R/boxr_misc.R
Outdated
|
|
||
| n_so_far = 0 | ||
|
|
||
| out = list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be here twice?
R/boxr_misc.R
Outdated
| box_pagination <- function(url, max = 200) { | ||
| box_paginate_marker = function(url, max){ | ||
|
|
||
| out = list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the convention of the package to use <- for assignment
| box_ls <- function(dir_id = box_getwd(), limit = 100, max = Inf, fields = NULL, pageMode = 'marker') { | ||
|
|
||
| # maybe some logic here to check that limit <= 1000 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're here, could you add the logic make sure that limit is no more than 1000? If it is, I think it would be appropriate to set it to 1000 and issue a warning. Thanks!
R/boxr_misc.R
Outdated
|
|
||
| if (req$status_code == 404) { | ||
| message("box.com indicates that no results were found") | ||
| return() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might return NULL here.
This is picky, but it may be better to use if (identical(resp$status_code, 404L))
R/boxr_misc.R
Outdated
|
|
||
| url$query$usemarker = T | ||
|
|
||
| while(!is.null(marker)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a logical variable here, next_page, like box_paginate_offset().
|
Hi Ian, I agree with dropping support for offset-based pagination; there was no benefit that I could see other than preserving legacy function. I will get these changed soon. Thanks! |
…and arguments. Pagination function is now once again `box_pagination()`. Warning emitted when limit > 1000 Other minor changes as requested.
|
Hi Ian, Wasn't sure if you were notified of this - I made the changes requested. Thanks for reviewing the code! |
|
Hi Alec, I hope to get to this in the next couple of days, thanks! |
|
Ok great thanks! I've had a few of my users use my fork without errors so
far, I will let you know if we encounter anything.
…On Mon, Jul 2, 2018, 15:23 Ian Lyttle ***@***.***> wrote:
Hi Alec,
I hope to get to this in the next couple of days, thanks!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#79 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/Aj2lF3jtp9HcdvmjzA1RJEkZMxYyBYqxks5uCizwgaJpZM4Uwrwf>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Alec,
This looks much cleaner - I am not surprised that it is working well for you and your colleagues. This will be a great improvement to the package as a whole.
My only requests are:
- formatting, to follow the existing style.
- to add an item to NEWS.md - you will see an item there describing your previous improvement (on fields). Please refer to the original issue (#74, I believe)
- if you have not already, please add
fixes #74to a commit message.
Thanks!
Ian
R/boxr_misc.R
Outdated
| #' | ||
| #' @author Brendan Rocks \email{foss@@brendanrocks.com} and Ian Lyttle | ||
| #' | ||
| #' @author Brendan Rocks \email{foss@@brendanrocks.com} and Ian Lyttle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add yourself to @authors of this function?
R/boxr_misc.R
Outdated
| box_ls <- function(dir_id = box_getwd(), limit = 100, max = Inf, fields = NULL) { | ||
|
|
||
| # maybe some logic here to check that limit <= 1000 | ||
| if(limit > 1000){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic looks good here - could you format to match the spacing and indentation of the code at L41, and use <- for assignment?
Could you do this for the other logic blocks (if, while) and use <- for assignment, generally?
|
Thanks Ian! I will get to these soon; I'm just returning from travel so I can address the last bits now. |
…ed myself to authors.
…package conventions
One of my users attempted to connect to a shared folder that they were not a member of, and the additional information would have been helpful to isolate the problem from my end.
|
Hi Ian, I made those changes that you requested. I also took the liberty to make the 404 error a little more explicit (see 12834e4; I had a user try to connect to a shared folder that they were not a member of, and I think the extra information could have made me see the problem sooner. Thanks for the review! Alec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks super, thanks!
Problem: [Issue #74]
Offset-based pagination has an offset limit of 300,000 which is not stated in the Box API documentation, but will be added following conversation with the Box team. The original function for
box_paginationhas been renamed asbox_paginate_offsetto preserve original functionality.Solution
The team recommended the use of marker-based pagination. Marker-based pagination is, according to the Box API docs, "the preferred method and is most performant", and so this change makes marker-based pagination the default method for GET-ting folder items.
Tests
My tests succeed in comparing and syncing my local set of files to the remote set of my box folder with quantity of files >330,000 where offset-based pagination returns an HTTP 400 error. Microbenchmark of the tests show comparable time to query 100,000 file names