refactor: Improve endpoint uniqueness check in create_flow function
This commit is contained in:
parent
29759f2c3e
commit
eeb3077b6f
1 changed files with 6 additions and 3 deletions
|
|
@ -51,9 +51,12 @@ def create_flow(
|
|||
else:
|
||||
flow.name = f"{flow.name} (1)"
|
||||
# Now check if the endpoint is unique
|
||||
if session.exec(
|
||||
select(Flow).where(Flow.endpoint_name == flow.endpoint_name).where(Flow.user_id == current_user.id)
|
||||
).first():
|
||||
if (
|
||||
flow.endpoint_name
|
||||
and session.exec(
|
||||
select(Flow).where(Flow.endpoint_name == flow.endpoint_name).where(Flow.user_id == current_user.id)
|
||||
).first()
|
||||
):
|
||||
flows = session.exec(
|
||||
select(Flow)
|
||||
.where(Flow.endpoint_name.like(f"{flow.endpoint_name}-%")) # type: ignore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue