-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathflows.py
More file actions
77 lines (66 loc) · 1.97 KB
/
flows.py
File metadata and controls
77 lines (66 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from collections.abc import Sequence
from typing import cast
from sqlalchemy import Connection, Row, text
def get_subflows(for_flow: int, expdb: Connection) -> Sequence[Row]:
return cast(
"Sequence[Row]",
expdb.execute(
text(
"""
SELECT child as child_id, identifier
FROM implementation_component
WHERE parent = :flow_id
""",
),
parameters={"flow_id": for_flow},
),
)
def get_tags(flow_id: int, expdb: Connection) -> list[str]:
tag_rows = expdb.execute(
text(
"""
SELECT tag
FROM implementation_tag
WHERE id = :flow_id
""",
),
parameters={"flow_id": flow_id},
)
return [tag.tag for tag in tag_rows]
def get_parameters(flow_id: int, expdb: Connection) -> Sequence[Row]:
return cast(
"Sequence[Row]",
expdb.execute(
text(
"""
SELECT *, defaultValue as default_value, dataType as data_type
FROM input
WHERE implementation_id = :flow_id
""",
),
parameters={"flow_id": flow_id},
),
)
def get_by_name(name: str, external_version: str, expdb: Connection) -> Row | None:
"""Gets flow by name and external version."""
return expdb.execute(
text(
"""
SELECT *, uploadDate as upload_date
FROM implementation
WHERE name = :name AND external_version = :external_version
""",
),
parameters={"name": name, "external_version": external_version},
).one_or_none()
def get(id_: int, expdb: Connection) -> Row | None:
return expdb.execute(
text(
"""
SELECT *, uploadDate as upload_date
FROM implementation
WHERE id = :flow_id
""",
),
parameters={"flow_id": id_},
).one_or_none()