From 04b047a823430957b4e4e699275a3372e1235149 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Wed, 1 Nov 2023 08:58:21 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(store.py):=20fix=20indentati?= =?UTF-8?q?on=20issue=20and=20remove=20unnecessary=20comments=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(schema.py):=20remove=20default=20value=20for?= =?UTF-8?q?=20liked=5Fby=5Fuser=20attribute=20in=20ListComponentResponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The indentation issue in `store.py` was causing the code to execute the wrong logic. The unnecessary comments were removed to improve code readability. In `schema.py`, the default value for the `liked_by_user` attribute in the `ListComponentResponse` class was removed to ensure that it is only set when needed. --- src/backend/langflow/api/v1/store.py | 10 +++++----- src/backend/langflow/services/store/schema.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/langflow/api/v1/store.py b/src/backend/langflow/api/v1/store.py index 8eaf4d200..5856cfa79 100644 --- a/src/backend/langflow/api/v1/store.py +++ b/src/backend/langflow/api/v1/store.py @@ -84,19 +84,19 @@ def list_components( limit=limit, filter_by_user=filter_by_user, ) - # Now, from the result, we need to get the components - # the user likes and set the liked_by_user to True + if not store_api_Key: return result + # Now, from the result, we need to get the components + # the user likes and set the liked_by_user to True liked_by_user_ids = store_service.get_liked_by_user_components( component_ids=[str(component.id) for component in result], api_key=store_api_Key, ) - # Now we need to set the liked_by_user to True + # Now we need to set the liked_by_user attribute for component in result: - if str(component.id) in liked_by_user_ids: - component.liked_by_user = True + component.liked_by_user = str(component.id) in liked_by_user_ids return result except Exception as exc: diff --git a/src/backend/langflow/services/store/schema.py b/src/backend/langflow/services/store/schema.py index 71e61b2da..54c6ff91c 100644 --- a/src/backend/langflow/services/store/schema.py +++ b/src/backend/langflow/services/store/schema.py @@ -42,7 +42,7 @@ class ListComponentResponse(BaseModel): name: Optional[str] description: Optional[str] liked_by_count: Optional[int] - liked_by_user: Optional[bool] = False + liked_by_user: Optional[bool] is_component: Optional[bool] metadata: Optional[dict] user_created: Optional[dict]