(self, queryset, indicator_prefix, range_name, all_types=None)
Given a QuerySet containing data for case based indicators generate the 'by_case'
        indicators before adding them to the data set.

        QuerySet expected to contain the following columns:
        *  case_owner:  ID of the case owner - User or Group.
        *  type:        The case type.
        *  count:       The value of the indicator for the owner and the case type.

        Also include default values for any case_types that are missing from the QuerySet
Given a QuerySet containing data for case based indicators generate the 'by_case'
        indicators before adding them to the data set.
Given a QuerySet containing data for case based indicators generate the by_case indicators before adding them to the data set .
def _add_case_data_by_type(self, queryset, indicator_prefix, range_name, all_types=None):
        """
        Given a QuerySet containing data for case based indicators generate the 'by_case'
        indicators before adding them to the data set.

        QuerySet expected to contain the following columns:
        *  case_owner:  ID of the case owner - User or Group.
        *  type:        The case type.
        *  count:       The value of the indicator for the owner and the case type.

        Also include default values for any case_types that are missing from the QuerySet
        """
        type_data = defaultdict(lambda: defaultdict(lambda: 0))
        for result in queryset:
            owner = result['owner_id']
            count = result['count']
            case_type = result['type']
            self._update_dataset(type_data[case_type], owner, count)

        seen_types = set()
        for case_type, data in type_data.items():
            self._reformat_and_add(data, '{}_{}_{}'.format(indicator_prefix, case_type, range_name))
            seen_types.add(case_type)

        all_types = all_types or self.case_types
        # add data for case types with no data
        unseen_cases = all_types - seen_types
        for case_type in unseen_cases:
            self._add_data([], '{}_{}_{}'.format(indicator_prefix, case_type, range_name))
def _add_case_data_by_type ( self , queryset , indicator_prefix , range_name , all_types = None ) : type_data = defaultdict ( lambda : defaultdict ( lambda : 0 ) ) for result in queryset : owner = result [ 'owner_id' ] count = result [ 'count' ] case_type = result [ 'type' ] self . _update_dataset ( type_data [ case_type ] , owner , count ) seen_types = set ( ) for case_type , data in type_data . items ( ) : self . _reformat_and_add ( data , '{}_{}_{}' . format ( indicator_prefix , case_type , range_name ) ) seen_types . add ( case_type ) all_types = all_types or self . case_types # add data for case types with no data unseen_cases = all_types - seen_types for case_type in unseen_cases : self . _add_data ( [ ] , '{}_{}_{}' . format ( indicator_prefix , case_type , range_name ) )