From 71000aad35748d6bf0b5b5bb737f327094f8a492 Mon Sep 17 00:00:00 2001 From: Untone Date: Tue, 19 Dec 2023 15:03:27 +0300 Subject: [PATCH] search-debug --- services/search.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/search.py b/services/search.py index 967c15fc..8c66e74f 100644 --- a/services/search.py +++ b/services/search.py @@ -24,13 +24,14 @@ class SearchService: if not cached: async with SearchService.lock: # Use aiohttp to send a request to ElasticSearch - # TODO: add limit offset usage async with aiohttp.ClientSession() as session: search_url = f"https://search.discours.io/search?q={text}" async with session.get(search_url) as response: if response.status == 200: payload = await response.json() await redis.execute("SET", text, json.dumps(payload)) - return payload + return payload[offset : offset + limit] + else: + print(f"[services.search] response: {response.status} {response.text}") else: - return json.loads(cached) + return json.loads(cached)[offset : offset + limit]