@@ -72,8 +72,6 @@ class GraphQLProject:
72
72
name : str
73
73
dataset : str
74
74
meta : strawberry .scalars .JSON
75
- read_group_name : str | None = None
76
- write_group_name : str | None = None
77
75
78
76
@staticmethod
79
77
def from_internal (internal : Project ) -> 'GraphQLProject' :
@@ -82,8 +80,6 @@ def from_internal(internal: Project) -> 'GraphQLProject':
82
80
name = internal .name ,
83
81
dataset = internal .dataset ,
84
82
meta = internal .meta ,
85
- read_group_name = internal .read_group_name ,
86
- write_group_name = internal .write_group_name ,
87
83
)
88
84
89
85
@strawberry .field ()
@@ -492,9 +488,11 @@ async def analyses(
492
488
if project :
493
489
ptable = ProjectPermissionsTable (connection .connection )
494
490
project_ids = project .all_values ()
495
- project_id_map = await ptable .get_project_id_map_for_names (
496
- author = connection .author , project_names = project_ids , readonly = True
491
+ projects = await ptable .get_and_check_access_to_projects_for_names (
492
+ user = connection .author , project_names = project_ids , readonly = True
497
493
)
494
+ project_id_map = {p .name : p .id for p in projects }
495
+
498
496
analyses = await loader .load (
499
497
{
500
498
'id' : root .internal_id ,
@@ -562,11 +560,10 @@ def enum(self, info: Info) -> GraphQLEnum:
562
560
async def project (self , info : Info , name : str ) -> GraphQLProject :
563
561
connection = info .context ['connection' ]
564
562
ptable = ProjectPermissionsTable (connection .connection )
565
- project_id = await ptable .get_project_id_from_name_and_user (
563
+ project = await ptable .get_and_check_access_to_project_for_name (
566
564
user = connection .author , project_name = name , readonly = True
567
565
)
568
- presponse = await ptable .get_projects_by_ids ([project_id ])
569
- return GraphQLProject .from_internal (presponse [0 ])
566
+ return GraphQLProject .from_internal (project )
570
567
571
568
@strawberry .field
572
569
async def sample (
@@ -590,11 +587,13 @@ async def sample(
590
587
if external_id and not project :
591
588
raise ValueError ('Must provide project when using external_id filter' )
592
589
590
+ project_name_map : dict [str , int ] = {}
593
591
if project :
594
592
project_ids = project .all_values ()
595
- project_id_map = await ptable .get_project_id_map_for_names (
596
- author = connection .author , project_names = project_ids , readonly = True
593
+ projects = await ptable .get_and_check_access_to_projects_for_ids (
594
+ user = connection .author , project_ids = project_ids , readonly = True
597
595
)
596
+ project_name_map = {p .name : p .id for p in projects }
598
597
599
598
filter_ = SampleFilter (
600
599
id = id .to_internal_filter (sample_id_transform_to_raw ) if id else None ,
@@ -604,7 +603,7 @@ async def sample(
604
603
participant_id = participant_id .to_internal_filter ()
605
604
if participant_id
606
605
else None ,
607
- project = project .to_internal_filter (lambda pname : project_id_map [pname ])
606
+ project = project .to_internal_filter (lambda pname : project_name_map [pname ])
608
607
if project
609
608
else None ,
610
609
active = active .to_internal_filter () if active else GenericFilter (eq = True ),
@@ -635,9 +634,10 @@ async def sequencing_groups(
635
634
project_id_map = {}
636
635
if project :
637
636
project_ids = project .all_values ()
638
- project_id_map = await ptable .get_project_id_map_for_names (
639
- author = connection .author , project_names = project_ids , readonly = True
637
+ projects = await ptable .get_and_check_access_to_projects_for_ids (
638
+ user = connection .author , project_ids = project_ids , readonly = True
640
639
)
640
+ project_id_map = {p .name : p .id for p in projects }
641
641
642
642
filter_ = SequencingGroupFilter (
643
643
project = project .to_internal_filter (lambda val : project_id_map [val ])
@@ -681,10 +681,9 @@ async def family(self, info: Info, family_id: int) -> GraphQLFamily:
681
681
async def my_projects (self , info : Info ) -> list [GraphQLProject ]:
682
682
connection = info .context ['connection' ]
683
683
ptable = ProjectPermissionsTable (connection .connection )
684
- project_map = await ptable .get_projects_accessible_by_user (
684
+ projects = await ptable .get_projects_accessible_by_user (
685
685
connection .author , readonly = True
686
686
)
687
- projects = await ptable .get_projects_by_ids (list (project_map .keys ()))
688
687
return [GraphQLProject .from_internal (p ) for p in projects ]
689
688
690
689
0 commit comments