fix(platform): Always filter on user id (#8275)
* always filter on user id * add user id to doc string * fix linting * fix imports functionbently/secrt-881-find-local-businesses-using-google-maps-list-building^2
parent
d742019349
commit
61f1d0cdb5
|
@ -382,9 +382,9 @@ async def get_node(node_id: str) -> Node:
|
||||||
|
|
||||||
|
|
||||||
async def get_graphs_meta(
|
async def get_graphs_meta(
|
||||||
|
user_id: str,
|
||||||
include_executions: bool = False,
|
include_executions: bool = False,
|
||||||
filter_by: Literal["active", "template"] | None = "active",
|
filter_by: Literal["active", "template"] | None = "active",
|
||||||
user_id: str | None = None,
|
|
||||||
) -> list[GraphMeta]:
|
) -> list[GraphMeta]:
|
||||||
"""
|
"""
|
||||||
Retrieves graph metadata objects.
|
Retrieves graph metadata objects.
|
||||||
|
@ -393,6 +393,7 @@ async def get_graphs_meta(
|
||||||
Args:
|
Args:
|
||||||
include_executions: Whether to include executions in the graph metadata.
|
include_executions: Whether to include executions in the graph metadata.
|
||||||
filter_by: An optional filter to either select templates or active graphs.
|
filter_by: An optional filter to either select templates or active graphs.
|
||||||
|
user_id: The ID of the user that owns the graph.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[GraphMeta]: A list of objects representing the retrieved graph metadata.
|
list[GraphMeta]: A list of objects representing the retrieved graph metadata.
|
||||||
|
@ -404,8 +405,7 @@ async def get_graphs_meta(
|
||||||
elif filter_by == "template":
|
elif filter_by == "template":
|
||||||
where_clause["isTemplate"] = True
|
where_clause["isTemplate"] = True
|
||||||
|
|
||||||
if user_id and filter_by != "template":
|
where_clause["userId"] = user_id
|
||||||
where_clause["userId"] = user_id
|
|
||||||
|
|
||||||
graphs = await AgentGraph.prisma().find_many(
|
graphs = await AgentGraph.prisma().find_many(
|
||||||
where=where_clause,
|
where=where_clause,
|
||||||
|
@ -585,7 +585,9 @@ TEMPLATES_DIR = Path(__file__).parent.parent.parent / "graph_templates"
|
||||||
|
|
||||||
|
|
||||||
async def import_packaged_templates() -> None:
|
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...")
|
logging.info("Loading templates...")
|
||||||
for template_file in TEMPLATES_DIR.glob("*.json"):
|
for template_file in TEMPLATES_DIR.glob("*.json"):
|
||||||
|
|
Loading…
Reference in New Issue