Merge branch 'feature/store' of github.com:logspace-ai/langflow into feature/store

This commit is contained in:
cristhianzl 2023-11-02 09:57:13 -03:00
commit 192f8f061e
2 changed files with 8 additions and 1 deletions

View file

@ -107,10 +107,13 @@ def count_components(
filter_by_user: bool = Query(False),
store_service: StoreService = Depends(get_store_service),
store_api_Key: str = Depends(get_optional_user_store_api_key),
is_component: Optional[bool] = Query(None),
):
try:
result = store_service.count_components(
api_key=store_api_Key, filter_by_user=filter_by_user
api_key=store_api_Key,
filter_by_user=filter_by_user,
is_component=is_component,
)
return {"count": result}
except Exception as exc:

View file

@ -167,6 +167,7 @@ class StoreService(Service):
self,
api_key: Optional[str] = None,
filter_by_user: bool = False,
is_component: Optional[bool] = None,
) -> int:
params = {"aggregate": json.dumps({"count": "*"})}
if filter_by_user:
@ -179,6 +180,9 @@ class StoreService(Service):
)
else:
params["filter"] = json.dumps({"status": {"_in": ["public", "Public"]}})
if is_component:
params["filter[is_component][_eq]"] = is_component
results = self._get(self.components_url, api_key, params)
return results[0].get("count", 0)