From 4193ec9b30b704e5c48ae6606d7da945b1d1a51f Mon Sep 17 00:00:00 2001 From: dzaslavskiy Date: Thu, 12 Oct 2023 17:52:28 -0400 Subject: [PATCH] Fix to avoid returning many false items if no interactionids found (#74) --- gdrive/export_api.py | 4 ++-- gdrive/export_client.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdrive/export_api.py b/gdrive/export_api.py index 350d31c..35a5ef0 100644 --- a/gdrive/export_api.py +++ b/gdrive/export_api.py @@ -7,7 +7,7 @@ import logging import fastapi -from pydantic import BaseModel +from pydantic import BaseModel, Field from fastapi import BackgroundTasks, responses from gdrive import export_client, client, settings, error @@ -121,7 +121,7 @@ class FindModel(BaseModel): responseId: str field: str - values: list[str] + values: list[str] = Field(..., min_items=1) result_field: str | None = None diff --git a/gdrive/export_client.py b/gdrive/export_client.py index 726cb57..6e1ef36 100644 --- a/gdrive/export_client.py +++ b/gdrive/export_client.py @@ -274,6 +274,9 @@ def find(responseId, field, values, result): all_interactionIds = get_all_InteractionIds(responseId) + if len(all_interactionIds) == 0: + return {"found": []} + all_interactionIds_match = list( map(lambda res: {"match": {"interactionId": f"{res}"}}, all_interactionIds) )