55from strawberry import Info , auto , field
66from strawberry .enum import EnumType
77
8+ from api .activities import usecase
89from api .models import (
910 Organization ,
1011 UseCase ,
12+ UseCaseDashboard ,
1113 UseCaseMetadata ,
1214 UseCaseOrganizationRelationship ,
1315)
1416from api .types .base_type import BaseType
1517from api .types .type_dataset import TypeDataset , TypeTag
1618from api .types .type_organization import TypeOrganization
1719from api .types .type_sector import TypeSector
20+ from api .types .type_usecase_dashboard import TypeUseCaseDashboard
1821from api .types .type_usecase_metadata import TypeUseCaseMetadata
1922from api .types .type_usecase_organization import TypeUseCaseOrganizationRelationship
2023from api .utils .enums import OrganizationRelationshipType , UseCaseStatus
@@ -75,15 +78,17 @@ def datasets(self) -> Optional[List["TypeDataset"]]:
7578 except Exception :
7679 return []
7780
78- @strawberry .field
81+ @strawberry .field (
82+ description = "Get the count of datasets associated with this use case."
83+ )
7984 def dataset_count (self : "TypeUseCase" , info : Info ) -> int :
8085 """Get the count of datasets associated with this use case."""
8186 try :
8287 return self .datasets .count () # type: ignore
8388 except Exception :
8489 return 0
8590
86- @strawberry .field
91+ @strawberry .field ( description = "Get publishers associated with this use case." )
8792 def publishers (self ) -> Optional [List ["TypeOrganization" ]]:
8893 """Get publishers associated with this use case."""
8994 try :
@@ -94,7 +99,7 @@ def publishers(self) -> Optional[List["TypeOrganization"]]:
9499 except Exception :
95100 return []
96101
97- @strawberry .field
102+ @strawberry .field ( description = "Get sectors associated with this use case." )
98103 def sectors (self ) -> Optional [List ["TypeSector" ]]:
99104 """Get sectors associated with this use case."""
100105 try :
@@ -105,7 +110,7 @@ def sectors(self) -> Optional[List["TypeSector"]]:
105110 except Exception :
106111 return []
107112
108- @strawberry .field
113+ @strawberry .field ( description = "Get tags associated with this use case." )
109114 def tags (self ) -> Optional [List ["TypeTag" ]]:
110115 """Get tags associated with this use case."""
111116 try :
@@ -116,7 +121,7 @@ def tags(self) -> Optional[List["TypeTag"]]:
116121 except Exception :
117122 return []
118123
119- @strawberry .field
124+ @strawberry .field ( description = "Get metadata associated with this use case." )
120125 def metadata (self ) -> Optional [List ["TypeUseCaseMetadata" ]]:
121126 """Get metadata associated with this use case."""
122127 try :
@@ -127,7 +132,7 @@ def metadata(self) -> Optional[List["TypeUseCaseMetadata"]]:
127132 except Exception :
128133 return []
129134
130- @strawberry .field
135+ @strawberry .field ( description = "Get contributors associated with this use case." )
131136 def contributors (self ) -> Optional [List ["TypeUser" ]]:
132137 """Get contributors associated with this use case."""
133138 try :
@@ -138,7 +143,9 @@ def contributors(self) -> Optional[List["TypeUser"]]:
138143 except Exception :
139144 return []
140145
141- @strawberry .field
146+ @strawberry .field (
147+ description = "Get organization relationships associated with this use case."
148+ )
142149 def organization_relationships (
143150 self ,
144151 ) -> Optional [List ["TypeUseCaseOrganizationRelationship" ]]:
@@ -151,7 +158,7 @@ def organization_relationships(
151158 except Exception :
152159 return []
153160
154- @strawberry .field
161+ @strawberry .field ( description = "Get supporting organizations for this use case." )
155162 def supporting_organizations (self ) -> Optional [List ["TypeOrganization" ]]:
156163 """Get supporting organizations for this use case."""
157164 try :
@@ -168,7 +175,7 @@ def supporting_organizations(self) -> Optional[List["TypeOrganization"]]:
168175 except Exception :
169176 return []
170177
171- @strawberry .field
178+ @strawberry .field ( description = "Get partner organizations for this use case." )
172179 def partner_organizations (self ) -> Optional [List ["TypeOrganization" ]]:
173180 """Get partner organizations for this use case."""
174181 try :
@@ -184,3 +191,16 @@ def partner_organizations(self) -> Optional[List["TypeOrganization"]]:
184191 return TypeOrganization .from_django_list (organizations )
185192 except Exception :
186193 return []
194+
195+ @strawberry .field (
196+ description = "Get Usecase dashboard associated with this use case."
197+ )
198+ def usecase_dashboard (self ) -> Optional [List ["TypeUseCaseDashboard" ]]:
199+ """Get Usecase dashboard associated with this use case."""
200+ try :
201+ usecase_dashboards = UseCaseDashboard .objects .filter (usecase = self ) # type: ignore
202+ if not usecase_dashboards .exists ():
203+ return []
204+ return TypeUseCaseDashboard .from_django_list (usecase_dashboards )
205+ except Exception :
206+ return []
0 commit comments