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

total_count support #7

Merged
merged 10 commits into from Feb 2, 2014
Merged

total_count support #7

merged 10 commits into from Feb 2, 2014

Conversation

andreiavram
Copy link
Contributor

total_count is sent by Redmine to all of the lists and is really useful especially when "paginating" results.

One issue might be the fact that with lazy-evaluating Resources / ResourceSets, total_count will not be available until AFTER evaluation, so forcing evaluation might be necessary (e.g calling list(issue_list)). However, total_count is especially useful when working with a subset (limit, offset) of resources, so evaluating the whole set might not be such a big problem.

@maxtepkeev maxtepkeev merged commit 69641c0 into maxtepkeev:master Feb 2, 2014
@ghost ghost assigned maxtepkeev Feb 2, 2014
@maxtepkeev
Copy link
Owner

Thanks, but it wasn't that simple actually.

First of all not all resources support limit/offset via Redmine directly, so I had to mimic this feature on the Python side for resources that needs it.

Also there are ResourceSet's which aren't created via all() and filter() methods but created automatically when requested from some other resource, e.g. project.custom_fields, for such ResourceSet's the total_count attribute returns the current available amount of resources that ResourceSet currently holds.

Lastly the total_count attribute doesn't belong to the ResourceManager in any way, so I moved it to the ResourceSet. To make that work I completely refactored the ResourceManager's retrieve() method which already violated the DRY principles so this is a good thing and I planned to do that anyway.

Once again thanks for the ideas. Waiting for new ones ;-)

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

Successfully merging this pull request may close these issues.

None yet

2 participants