-
Notifications
You must be signed in to change notification settings - Fork 23
enforce exact max results in search_entities #907
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -439,12 +439,11 @@ def search_entities(search_string: str, language: str | None = None, strict_lang | |
|
|
||
| language = str(language or config['DEFAULT_LANGUAGE']) | ||
|
|
||
| params = { | ||
| params: dict[str, str | int] = { | ||
| 'action': 'wbsearchentities', | ||
| 'search': search_string, | ||
| 'language': language, | ||
| 'type': search_type, | ||
| 'limit': 50, | ||
| 'format': 'json' | ||
| } | ||
|
|
||
|
|
@@ -455,7 +454,8 @@ def search_entities(search_string: str, language: str | None = None, strict_lang | |
| results = [] | ||
|
|
||
| while True: | ||
| params.update({'continue': cont_count}) | ||
| max_page_results = min(50, max_results - cont_count) | ||
| params.update({'continue': cont_count, 'limit': max_page_results}) | ||
|
Comment on lines
+457
to
+458
|
||
|
|
||
| search_results = mediawiki_api_call_helper(data=params, allow_anonymous=allow_anonymous, **kwargs) | ||
|
|
||
|
|
||
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.
More than open to style and logic suggestions.
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.
BTW, it seems we could move the
cont_count < max_resultscriteria into theWhilecondition above (and save 3 lines at the bottom of the function).