-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query for Assessment registry Count
- total assessment count - total stakeholder count - collection technique count - multisector and single sector assessment - filter with affected groups - filter with location,family,frequency,coordination_type,assessment_type and focus
- Loading branch information
Showing
5 changed files
with
226 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import django_filters | ||
|
||
from deep.filter_set import generate_type_for_filter_set, OrderEnumMixin | ||
from user_resource.filters import UserResourceGqlFilterSet | ||
from .models import AssessmentRegistry | ||
from utils.graphene.filters import IDListFilter, IDFilter,MultipleInputFilter | ||
from .enums import( | ||
AssessmentRegistryAffectedGroupTypeEnum, | ||
AssessmentRegistryCoordinationTypeEnum, | ||
AssessmentRegistryDetailTypeEnum, | ||
AssessmentRegistryFamilyTypeEnum, | ||
AssessmentRegistryFrequencyTypeEnum, | ||
AssessmentRegistryFocusTypeEnum | ||
) | ||
|
||
class AssessmentDashboardFilterSet(OrderEnumMixin, UserResourceGqlFilterSet): | ||
stakeholder = IDListFilter(method="filter_stakeholder") | ||
lead_organization = IDListFilter(method="filter_lead_organization") | ||
location = IDListFilter(method="filter_location") | ||
affected_group = MultipleInputFilter(AssessmentRegistryAffectedGroupTypeEnum,method="filter_affected_group") | ||
family = MultipleInputFilter(AssessmentRegistryFamilyTypeEnum) | ||
frequency = MultipleInputFilter(AssessmentRegistryFrequencyTypeEnum) | ||
coordination_type = MultipleInputFilter(AssessmentRegistryCoordinationTypeEnum,field_name='coordinated_joint') | ||
assessment_type = MultipleInputFilter(AssessmentRegistryDetailTypeEnum,field_name='details_type') | ||
focuses=MultipleInputFilter(AssessmentRegistryFocusTypeEnum,method='filter_focuses') | ||
|
||
class Meta: | ||
model = AssessmentRegistry | ||
fields = () | ||
|
||
def filter_stakeholder(self, qs, _, value): | ||
pass # TODO: when stakeholder is managed in single field | ||
|
||
def filter_lead_organization(self, qs, _, value): | ||
pass # TODO: when stakeholder is managed in single field | ||
|
||
def filter_location(self, qs, _, value): | ||
return qs if value is None else qs.filter(locations__in=list(map(int, value))) ##change value (list of decimal) into int list | ||
|
||
def filter_affected_group(self, qs, _, value): | ||
return qs if value is None else qs.filter(affected_groups__overlap=value) | ||
|
||
def filter_focuses(self, qs, _, value): | ||
return qs if value is None else qs.filter(focuses__overlap=value) | ||
|
||
AssessmentDashboardFilterDataType,AssessmentDashboardFilterDataInputType,= generate_type_for_filter_set( | ||
AssessmentDashboardFilterSet, | ||
"project.schema.ProjectListType", | ||
"AssessmentDashboardFilterDataType", | ||
"AssessmentDashboardFilterDataInputType", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters