Skip to content

Commit 1ea955f

Browse files
authored
Merge pull request #11770 from internetarchive/async-renaming
Standardize async function naming convention
2 parents efe1865 + 9ba111e commit 1ea955f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

openlibrary/fastapi/search.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
from openlibrary.core.fulltext import fulltext_search_async
2121
from openlibrary.fastapi.models import Pagination, PaginationLimit20
2222
from openlibrary.plugins.worksearch.code import (
23-
async_run_solr_query,
2423
default_spellcheck_count,
24+
run_solr_query_async,
2525
validate_search_json_query,
2626
work_search_async,
2727
)
@@ -226,7 +226,7 @@ async def search_subjects_json(
226226
pagination: Annotated[Pagination, Depends()],
227227
q: str = Query("", description="The search query"),
228228
):
229-
response = await async_run_solr_query(
229+
response = await run_solr_query_async(
230230
SubjectSearchScheme(),
231231
{'q': q},
232232
offset=pagination.offset,
@@ -306,7 +306,7 @@ def handle_legacy_logic(self) -> Self:
306306
async def search_lists_json(
307307
params: Annotated[ListSearchRequestParams, Depends()],
308308
):
309-
response = await async_run_solr_query(
309+
response = await run_solr_query_async(
310310
ListSearchScheme(),
311311
{'q': params.q},
312312
offset=params.offset,
@@ -348,7 +348,7 @@ class AuthorSearchRequestParams(Pagination):
348348
async def search_authors_json(
349349
params: Annotated[AuthorSearchRequestParams, Depends()],
350350
):
351-
response = await async_run_solr_query(
351+
response = await run_solr_query_async(
352352
AuthorSearchScheme(),
353353
{'q': params.q},
354354
offset=params.offset,

openlibrary/plugins/worksearch/code.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def process_facet_counts(
156156
yield field, list(process_facet(field, web.group(facets, 2)))
157157

158158

159-
async def async_execute_solr_query(
159+
async def execute_solr_query_async(
160160
solr_path: str,
161161
params: dict | list[tuple[str, Any]],
162162
_timeout: int | None = DEFAULT_SOLR_TIMEOUT_SECONDS,
@@ -180,7 +180,7 @@ async def async_execute_solr_query(
180180
return response
181181

182182

183-
execute_solr_query = async_bridge.wrap(async_execute_solr_query)
183+
execute_solr_query = async_bridge.wrap(execute_solr_query_async)
184184

185185
# Expose this publicly
186186
public(has_solr_editions_enabled)
@@ -381,7 +381,7 @@ def run_solr_query(
381381
)
382382

383383

384-
async def async_run_solr_query(
384+
async def run_solr_query_async(
385385
scheme: SearchScheme,
386386
param: dict | None = None,
387387
**kwargs,
@@ -393,7 +393,7 @@ async def async_run_solr_query(
393393

394394
url = f'{solr_select_url}?{urlencode(params)}'
395395
start_time = time.time()
396-
response = await async_execute_solr_query(solr_select_url, params)
396+
response = await execute_solr_query_async(solr_select_url, params)
397397
end_time = time.time()
398398
duration = end_time - start_time
399399

@@ -1136,7 +1136,7 @@ async def work_search_async(
11361136
) -> dict:
11371137
prepared = _prepare_work_search_query(query, page, offset, limit)
11381138
scheme = WorkSearchScheme(lang=lang)
1139-
resp = await async_run_solr_query(
1139+
resp = await run_solr_query_async(
11401140
scheme,
11411141
prepared.query,
11421142
rows=prepared.limit,

openlibrary/plugins/worksearch/subjects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ async def get_subject_async(
268268
# Circular imports are everywhere -_-
269269
from openlibrary.plugins.worksearch.code import (
270270
WorkSearchScheme,
271-
async_run_solr_query,
271+
run_solr_query_async,
272272
)
273273

274274
subject_type = self.name
@@ -279,7 +279,7 @@ async def get_subject_async(
279279
if 'publish_year' in filters:
280280
# Don't want this escaped or used in fq for perf reasons
281281
unescaped_filters['publish_year'] = filters.pop('publish_year')
282-
result = await async_run_solr_query(
282+
result = await run_solr_query_async(
283283
WorkSearchScheme(),
284284
{
285285
'q': query_dict_to_str(

0 commit comments

Comments
 (0)