|
11 | 11 | from django_cte import With # type: ignore[reportMissingTypeStubs] |
12 | 12 |
|
13 | 13 | from apps.community_dashboard.models import AggregatedUserGroupStatData, AggregatedUserStatData |
14 | | -from apps.contributor.models import ContributorUser |
| 14 | +from apps.contributor.models import ContributorUser, ContributorUserGroup |
15 | 15 | from apps.project.models import Project, ProjectTypeEnum |
16 | 16 | from utils.graphql.inputs import DateRangeInput |
17 | 17 | from utils.graphql.types import AreaSqKm, GenericJSON |
@@ -349,6 +349,10 @@ def __post_init__(self, user: ContributorUser): |
349 | 349 | async def id(self) -> strawberry.ID: |
350 | 350 | return typing.cast("strawberry.ID", self._user.pk) |
351 | 351 |
|
| 352 | + @strawberry.field |
| 353 | + async def firebase_id(self) -> strawberry.ID: |
| 354 | + return typing.cast("strawberry.ID", self._user.firebase_id) |
| 355 | + |
352 | 356 | @strawberry.field |
353 | 357 | async def stats(self) -> ContributorUserStatType: |
354 | 358 | # TODO: Cache this |
@@ -423,15 +427,15 @@ def __post_init__(self, date_range: DateRangeInput | None, user_group_id: int): |
423 | 427 |
|
424 | 428 | @strawberry.type |
425 | 429 | class ContributorUserGroupStats: |
426 | | - user_group_id: InitVar[int] |
| 430 | + user_group: InitVar[ContributorUserGroup] |
427 | 431 |
|
428 | 432 | _user_group_id: strawberry.Private[int] = dataclass_field(init=False) |
429 | 433 | _ug_qs: strawberry.Private[models.QuerySet[AggregatedUserGroupStatData]] = dataclass_field(init=False) |
430 | 434 |
|
431 | | - def __post_init__(self, user_group_id: int): |
432 | | - self._user_group_id = user_group_id |
| 435 | + def __post_init__(self, user_group: ContributorUserGroup): |
| 436 | + self._user_group_id = user_group.pk |
433 | 437 | self._ug_qs = AggregatedUserGroupStatData.objects.filter( |
434 | | - user_group_id=user_group_id, |
| 438 | + user_group_id=user_group.pk, |
435 | 439 | ) |
436 | 440 |
|
437 | 441 | @strawberry.field |
|
0 commit comments