From aa200e4aa683eb6875662265cef684a050720b54 Mon Sep 17 00:00:00 2001 From: Isaac Johnson Date: Tue, 7 Oct 2025 18:46:37 -0500 Subject: [PATCH] working search --- main.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 0a56dd8..fe41145 100644 --- a/main.py +++ b/main.py @@ -62,11 +62,22 @@ def search_tasks(query: str): # Vikunja does not expose a /tasks/search endpoint in the public API. # Fetch all tasks and filter client-side by title/description. logger.info("search_tasks: fetching all tasks from %s", f"{VIKUNJA_URL}/api/v1/tasks/all") - response = session.get(f"{VIKUNJA_URL}/api/v1/tasks/all") - response.raise_for_status() - data = response.json() - # The API might return a list or an object with a 'tasks' key - tasks = data if isinstance(data, list) else data.get("tasks", []) + + all_tasks = [] + page = 1 + per_page = 50 + + while True: + response = session.get(f"{VIKUNJA_URL}/api/v1/tasks/all?page={page}&limit={per_page}") + response.raise_for_status() + data = response.json() + tasks = data if isinstance(data, list) else data.get("tasks", []) + if not tasks: + break + all_tasks.extend(tasks) + page += 1 + + tasks = all_tasks q = (query or "").strip() logger.info("search_tasks: raw query='%s'", q)