fix(platform): Always filter on user id (#8275)

* always filter on user id

* add user id to doc string

* fix linting

* fix imports function
bently/secrt-881-find-local-businesses-using-google-maps-list-building^2
Aarushi 2024-10-07 14:47:49 +01:00 committed by GitHub
parent d742019349
commit 61f1d0cdb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -382,9 +382,9 @@ async def get_node(node_id: str) -> Node:
async def get_graphs_meta(
user_id: str,
include_executions: bool = False,
filter_by: Literal["active", "template"] | None = "active",
user_id: str | None = None,
) -> list[GraphMeta]:
"""
Retrieves graph metadata objects.
@ -393,6 +393,7 @@ async def get_graphs_meta(
Args:
include_executions: Whether to include executions in the graph metadata.
filter_by: An optional filter to either select templates or active graphs.
user_id: The ID of the user that owns the graph.
Returns:
list[GraphMeta]: A list of objects representing the retrieved graph metadata.
@ -404,7 +405,6 @@ async def get_graphs_meta(
elif filter_by == "template":
where_clause["isTemplate"] = True
if user_id and filter_by != "template":
where_clause["userId"] = user_id
graphs = await AgentGraph.prisma().find_many(
@ -585,7 +585,9 @@ TEMPLATES_DIR = Path(__file__).parent.parent.parent / "graph_templates"
async def import_packaged_templates() -> None:
templates_in_db = await get_graphs_meta(filter_by="template")
templates_in_db = await get_graphs_meta(
user_id=DEFAULT_USER_ID, filter_by="template"
)
logging.info("Loading templates...")
for template_file in TEMPLATES_DIR.glob("*.json"):