fixing-search #1

Merged
builderadmin merged 3 commits from fixing-search into main 2025-10-08 14:21:05 +00:00
1 changed files with 16 additions and 5 deletions
Showing only changes of commit aa200e4aa6 - Show all commits

15
main.py
View File

@ -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")
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()
# The API might return a list or an object with a 'tasks' key
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)