🔍 refactor(store.py): add support for filtering components based on is_component flag in list_components function
🔍 refactor(service.py): add support for filtering components based on is_component flag in get_components function
This commit is contained in:
parent
fad72c6e2c
commit
0c90c12c94
2 changed files with 6 additions and 1 deletions
|
|
@ -75,6 +75,7 @@ def list_components(
|
|||
filter_by_user: bool = Query(False),
|
||||
page: int = 1,
|
||||
limit: int = 10,
|
||||
is_component: Optional[bool] = Query(None),
|
||||
store_service: StoreService = Depends(get_store_service),
|
||||
store_api_Key: Optional[str] = Depends(get_optional_user_store_api_key),
|
||||
):
|
||||
|
|
@ -85,6 +86,7 @@ def list_components(
|
|||
page=page,
|
||||
limit=limit,
|
||||
filter_by_user=filter_by_user,
|
||||
is_component=is_component,
|
||||
)
|
||||
|
||||
if not store_api_Key:
|
||||
|
|
|
|||
|
|
@ -188,15 +188,18 @@ class StoreService(Service):
|
|||
page: int = 1,
|
||||
limit: int = 15,
|
||||
fields: Optional[List[str]] = None,
|
||||
is_component: Optional[bool] = None,
|
||||
filter_by_user: bool = False,
|
||||
) -> Union[List[ListComponentResponse], List[Dict[str, int]]]:
|
||||
params = {"page": page, "limit": limit}
|
||||
# ?aggregate[count]=likes
|
||||
params["fields"] = ",".join(fields) if fields else ",".join(self.default_fields)
|
||||
|
||||
if is_component:
|
||||
params["filter[is_component][_eq]"] = is_component
|
||||
|
||||
# Only public components or the ones created by the user
|
||||
# check for "public" or "Public"
|
||||
|
||||
if filter_by_user and not api_key:
|
||||
raise ValueError("No API key provided")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue