Skip to content
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

RightSignature::Document#documents_list returning incorrect total_pages #21

Open
jufemaiz opened this issue Nov 2, 2016 · 1 comment

Comments

@jufemaiz
Copy link

jufemaiz commented Nov 2, 2016

We currently have some 1800+ documents in RightSignature and are in the process of ensuring we have them stored in a redundant service.

Using the RightSignature API Gem, we've built a tool to extract these files en mass to take the pressure of our Administration team. We've thus come across a bug in the API or in the Gem (likely the Gem).

Calling the following:

documents_list = @rs_connection.documents_list(page: 1, per_page: 50, account: true, state: 'completed,pending,trash')

Yields the following:

{"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"1"}

Simple mathematics shows this is incorrect:

Calculated ceiling: 20 * 50 = 1000
Actual ceiling: 1900

Reported total_pages: 20
Expected total_pages: 38

Now, here's where it gets weird. If I iterate through my expected data set (again, I'm using per_page as 50 to ensure I get the widest net possible in my queries) I see the following response:

Page 1: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"1"}
Page 2: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"2"}
Page 3: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"3"}
Page 4: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"4"}
Page 5: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"5"}
Page 6: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"6"}
Page 7: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"7"}
Page 8: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"8"}
Page 9: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"9"}
Page 10: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"10"}
Page 11: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"11"}
Page 12: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"12"}
Page 13: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"13"}
Page 14: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"14"}
Page 15: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"15"}
Page 15: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"15"}
Page 16: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"16"}
Page 17: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"17"}
Page 18: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"18"}
Page 19: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"19"}
Page 20: {"total_documents"=>"1877", "total_pages"=>"20", "per_page"=>"50", "current_page"=>"20"}
Page 21: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"21"}
Page 22: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"22"}
Page 23: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"23"}
Page 24: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"24"}
Page 25: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"25"}
Page 26: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"26"}
Page 27: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"27"}
Page 28: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"28"}
Page 29: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"29"}
Page 30: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"30"}
Page 31: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"31"}
Page 32: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"32"}
Page 33: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"33"}
Page 34: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"34"}
Page 35: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"35"}
Page 36: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"36"}
Page 37: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"37"}
Page 38: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"38"}
Page 39: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"39"}
Page 40: {"total_documents"=>"1877", "total_pages"=>"38", "per_page"=>"50", "current_page"=>"40"}

Note that there is a switch between 20 & 21 that allows full visibility over the correct total_pages value. I've also tested two further pages for fun (39, 40). They do respond and I'm assuming that they'd deliver empty documents.document nodes.

@jufemaiz
Copy link
Author

jufemaiz commented Nov 2, 2016

Further to this, I've tested with different per_page values and they all default to a maximum number of records of 1000 to determine total_pages until you request a page for records greater than the first 1000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant