Beispiel #1
0
def get_stat_var_group(cc, data, places):
    """Get the stat var grouping for aggregation."""
    if 'aggregate' in cc:
        agg_type = lib_range.get_aggregate_config(cc['aggregate'])
        place_stat_vars = defaultdict(list)
        for place in places:
            if place not in data or 'data' not in data[place]:
                continue
            for sv in cc['statsVars']:
                if sv in data[place]['data']:
                    place_stat_vars[place].append(sv)
        result = lib_range.aggregate_stat_var(place_stat_vars, agg_type)
        for place in places:
            if place not in result:
                result[place] = {}
    else:
        result = {}
        for place in places:
            result[place] = {sv: [sv] for sv in cc['statsVars']}
    return result
Beispiel #2
0
 def test_aggregate_field(self):
     for chart in self.charts:
         if 'aggregate' in chart:
             agg_conf = lib_range.get_aggregate_config(chart['aggregate'])
             assert 'grouping' in agg_conf