Skip to content

Commit d395d30

Browse files
committed
add actve sectors query
1 parent 9b79387 commit d395d30

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

api/schema/sector_schema.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from api.models import Sector
1111
from api.types.type_sector import TypeSector
12+
from api.utils.enums import DatasetStatus
1213

1314

1415
@strawberry.input
@@ -40,6 +41,12 @@ def sector(self, info: Info, id: uuid.UUID) -> Optional[TypeSector]:
4041
except Sector.DoesNotExist:
4142
raise ValueError(f"Sector with ID {id} does not exist.")
4243

44+
@strawberry_django.field
45+
def active_sectors(self, info: Info) -> list[TypeSector]:
46+
"""Get sectors with published datasets."""
47+
queryset = Sector.objects.filter(datasets__status=DatasetStatus.PUBLISHED)
48+
return TypeSector.from_django_list(queryset)
49+
4350

4451
@strawberry.type
4552
class Mutation:

0 commit comments

Comments
 (0)