🔧 chore(service.py): add support for filtering components by user_created field
🔧 chore(service.py): add support for filtering components by user_created field when filter_by_user flag is set to True, otherwise filter by status field
This commit is contained in:
parent
e15d38e8d2
commit
3a21f6092a
1 changed files with 12 additions and 0 deletions
|
|
@ -72,6 +72,7 @@ class StoreService(Service):
|
|||
date_to: Optional[datetime] = None,
|
||||
sort: Optional[List[str]] = ["-likes"],
|
||||
fields: Optional[List[str]] = None,
|
||||
filter_by_user: bool = False,
|
||||
) -> List[ComponentResponse]:
|
||||
# ?sort=sort,-date_created,author.name
|
||||
|
||||
|
|
@ -104,6 +105,17 @@ class StoreService(Service):
|
|||
if fields:
|
||||
params["fields"] = ",".join(fields)
|
||||
|
||||
if filter_by_user:
|
||||
params["deep"] = json.dumps(
|
||||
{
|
||||
"components": {
|
||||
"_filter": {"user_created": {"token": {"_eq": api_key}}}
|
||||
}
|
||||
}
|
||||
)
|
||||
else:
|
||||
params["filter"] = json.dumps({"status": {"_eq": "public"}})
|
||||
|
||||
results = self._get(self.components_url, api_key, params)
|
||||
return [ComponentResponse(**component) for component in results]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue