-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Description
We are using yandex_tracker_client as a library on a backend to perform issue search in Yandex Tracker, where our backend app receives request from our frontend app and performs issue search depending on the issue tracker configured in the system.
The pagination controls are implemented on the front-end and are passed as parameters to client.issues.find() method to show, say, only the first page with 10 items on it. However, these parameters are ignored and client iterates over all results array, leading to Error 429 from Yandex Tracker.
That's, as we suspect, because of this method override:
https://github.com/yandex/yandex_tracker_client/blob/master/yandex_tracker_client/collections.py#L95
Steps to reproduce:
- Perform issue search as follows:
from yandex_tracker_client import TrackerClient
client = TrackerClient(token=YANDEX_OAUTH_TOKEN, org_id=YANDEX_ORG_ID, cloud_org_id=CLOUD_ORG_ID)
query = 'Key: test OR Summary: test OR Description: test'
search = client.issues.find(
query,
page=1,
per_page=10)
for issue in search:
print(issue)
Expected outcome:
Only first page of the search is returned with 10 items on it
Actual outcome:
- Client iterates over all results, making more than 1 request
- As a result, Error 429 is returned by Yandex Tracker API
Additional information
We can see how auto-iteration through all results may be useful, so probably it's worth creating two methods - findAll() that automatically iterates over all results, and the find() that obey the provided pagination parameters.