🐛 fix(store.py): fix indentation issue and remove unnecessary comments
🐛 fix(schema.py): remove default value for liked_by_user attribute in ListComponentResponse
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.
This commit is contained in:
parent
0c728ea58e
commit
04b047a823
2 changed files with 6 additions and 6 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue