Skip to content

Commit 77d26ec

Browse files
committed
fixes projecst repo
1 parent 2637c2c commit 77d26ec

File tree

2 files changed

+19
-26
lines changed

2 files changed

+19
-26
lines changed

services/director-v2/src/simcore_service_director_v2/modules/db/repositories/projects.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from models_library.projects import ProjectAtDB, ProjectID
55
from models_library.projects_nodes_io import NodeID
66
from simcore_postgres_database.utils_projects_nodes import ProjectNodesRepo
7+
from simcore_postgres_database.utils_repos import pass_or_acquire_connection
78

89
from ....core.errors import ProjectNotFoundError
9-
from ..tables import projects
10+
from ..tables import projects, projects_nodes
1011
from ._base import BaseRepository
1112

1213
logger = logging.getLogger(__name__)
@@ -27,11 +28,15 @@ async def get_project(self, project_id: ProjectID) -> ProjectAtDB:
2728
async def is_node_present_in_workbench(
2829
self, project_id: ProjectID, node_uuid: NodeID
2930
) -> bool:
30-
try:
31-
project = await self.get_project(project_id)
32-
return f"{node_uuid}" in project.workbench
33-
except ProjectNotFoundError:
34-
return False
31+
async with pass_or_acquire_connection(self.db_engine) as conn:
32+
result = await conn.execute(
33+
sa.select(projects_nodes.c.project_node_id).where(
34+
projects_nodes.c.project_uuid == str(project_id),
35+
projects_nodes.c.node_id == str(node_uuid),
36+
)
37+
)
38+
project_node = result.one_or_none()
39+
return project_node is not None
3540

3641
async def get_project_id_from_node(self, node_id: NodeID) -> ProjectID:
3742
async with self.db_engine.connect() as conn:
Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
1-
from simcore_postgres_database.models.comp_pipeline import StateType, comp_pipeline
2-
from simcore_postgres_database.models.comp_run_snapshot_tasks import (
3-
comp_run_snapshot_tasks,
4-
)
5-
from simcore_postgres_database.models.comp_runs import comp_runs
6-
from simcore_postgres_database.models.comp_tasks import NodeClass, comp_tasks
7-
from simcore_postgres_database.models.groups import user_to_groups
8-
from simcore_postgres_database.models.groups_extra_properties import (
9-
groups_extra_properties,
10-
)
11-
from simcore_postgres_database.models.projects import ProjectType, projects
12-
from simcore_postgres_database.models.projects_networks import projects_networks
13-
14-
__all__ = [
1+
__all__: tuple[str, ...] = (
2+
"NodeClass",
3+
"ProjectType",
4+
"StateType",
155
"comp_pipeline",
6+
"comp_run_snapshot_tasks",
167
"comp_runs",
178
"comp_tasks",
189
"groups_extra_properties",
19-
"NodeClass",
20-
"projects_networks",
2110
"projects",
22-
"ProjectType",
23-
"StateType",
11+
"projects_networks",
12+
"projects_nodes",
2413
"user_to_groups",
25-
"comp_run_snapshot_tasks",
26-
]
14+
)

0 commit comments

Comments
 (0)