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

Get a count of total records retrieved by the filter_tickets Method #56

Open
hanskohls opened this issue Jul 15, 2020 · 8 comments
Open

Comments

@hanskohls
Copy link

As a developer I would like to know the total count of tickets returned by a query_string so that I know if I cannot retrieve all the tickets in the query.

Hi Sam I really like this project and hope to use it quite a bit. But sadly you are shielding this fairly critical indicator in your implementation of filter_tickets.
My preferred implementation would be to simply have a method called total_records(self, query, **kwargs) which retrieve only one page but would get the total of records.
I'd be happy to fork and contribute this if you would like me to.

@sjkingo
Copy link
Owner

sjkingo commented Jul 15, 2020

Hi, filter_tickets() will iterate over all pages and return a list of all Ticket instances. Do you have a use-case where you cannot call that to fetch all and len() the result? (efficiency maybe?)

@sjkingo
Copy link
Owner

sjkingo commented Jul 15, 2020

I have just noticed we can only return the first 10 pages of tickets with the API. Is this the limitation you're running up against?

@hanskohls
Copy link
Author

hanskohls commented Jul 15, 2020

Yes, the API is limited to 10 pages with at most 30 records, so 300 in total. However the total field shows the total number.

I'd love to use your library, but would want to run a request first, see if there are more than 300 records and then split this request in to several requests with on of several dimension values. Ie. query by priority, date, status, assigned user, ...

If I make a request for each possible permutation I hit several thousand requests and this would run for nearly an hour (and until I get rate limited/or even blacklisted). So I want to check the record count for a less restrictive query first and only create the more restrictive one if I'm exceeding the limit of 300 tickets.

@sjkingo
Copy link
Owner

sjkingo commented Jul 15, 2020

Ok, that makes sense. You're welcome to fork if you want, however I've got an idea that would both implement what you are needing easily while maintaining backwards compatibility with the existing filter.

I'll report back soon.

@hanskohls
Copy link
Author

I'll check this on my tomorrow and can then fork or leave it to you. Thanks for this great library and support.

@hanskohls
Copy link
Author

Maybe to comment on one point here though, your query paginates automatically and that's triggering many requests which may not be needed (because the result can be incomplete) it would be useful if we can turn pagination off and get only a single record when retrieving the total number of records.

@sjkingo
Copy link
Owner

sjkingo commented Jul 15, 2020

Maybe to comment on one point here though, your query paginates automatically and that's triggering many requests which may not be needed (because the result can be incomplete) it would be useful if we can turn pagination off and get only a single record when retrieving the total number of records.

I agree, that was part of what I was thinking. Good catch!

@sjkingo
Copy link
Owner

sjkingo commented Jul 19, 2020

Apologies - I have been flat out and haven't had a chance yet 😄

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

2 participants