Ejemplo n.º 1
0
def find_denormalized():
    res = {}
    for cube in get_cubes():
        statistic = cube.get('statistic_name')
        if not statistic in res:
            res[statistic] = {}
        cube_name = cube.get('cube_name')
        dimensions = get_dimensions(cube_name)
        #pprint(dimensions)
        dimensions = [d for d in dimensions if not d['dim_measure_type'].startswith('K-REG-MM')]
        #dims = [(d['dim_name'], d['ref_type']) for d in dimensions]
        dims = [d['dim_name'] for d in dimensions]
        res[statistic][cube_name] = dims
    pprint(res)
Ejemplo n.º 2
0
def find_denormalized():
    res = {}
    for cube in get_cubes():
        statistic = cube.get('statistic_name')
        if not statistic in res:
            res[statistic] = {}
        cube_name = cube.get('cube_name')
        dimensions = get_dimensions(cube_name)
        #pprint(dimensions)
        dimensions = [
            d for d in dimensions
            if not d['dim_measure_type'].startswith('K-REG-MM')
        ]
        #dims = [(d['dim_name'], d['ref_type']) for d in dimensions]
        dims = [d['dim_name'] for d in dimensions]
        res[statistic][cube_name] = dims
    pprint(res)
Ejemplo n.º 3
0
def generate_cubes():
    cubes = []
    for cube in get_cubes():
        dimensions = []
        measures = []
        joins = []
        mappings = {}
        cube_name = cube.get('cube_name')
        for dim in get_dimensions(cube_name):
            dn = dim.get('dim_name')
            if dim.get('dim_measure_type').startswith('W-'):
                measures.append(dn)
                continue
            
            dimensions.append(dn)
            if dim.get('dim_measure_type').startswith('ZI-'):
                mappings[dn + '.text'] = 'fact_%s.%s' % (cube_name, dn)
                mappings[dn + '.from'] = 'fact_%s.%s_from' % (cube_name, dn)
                mappings[dn + '.until'] = 'fact_%s.%s_until' % (cube_name, dn)
            else:
                tn = 'tbl_' + dn
                joins.append({
                    'master': dn,
                    'detail': 'value.value_id',
                    'alias': tn
                    })
                mappings[dn + '.name'] = tn + '.name'
                mappings[dn + '.label'] = tn + '.title_de'

            
        cubes.append({
            'dimensions': dimensions,
            'measures': measures,
            'mappings': mappings,
            'joins': joins,
            'fact': 'fact_%s' % cube_name,
            'name': cube.get('cube_name'),
            'label': cube.get('statistic_title_de'),
            'description': cube.get('statistic_description_de'),
            })
    return cubes
Ejemplo n.º 4
0
def view(catalog, slug, name):
    catalog = get_catalog(catalog)
    statistic = statistic_table.find_one(name=name)
    desc = parse_description(statistic['description_de'] or '')
    cubes = []
    dims = defaultdict(int)
    titles = set([statistic['title_de']])
    for cube in get_cubes(name):
        cube['dimensions'] = get_dimensions(cube['name'])
        for dim in cube['dimensions']:
            dim['show'] = True
            dims[dim['dim_name']] += 1
            titles.add(dim['dim_title_de'])
            dim['type_text'] = dimension_type_text(dim['dim_measure_type'])
            if dim['dim_measure_type'].startswith('K-REG'):
                cube['admlevel'] = (ADM_RANKS[dim['dim_name']],
                                    dim['dim_title_de'], dim['dim_name'])
                dim['show'] = False
        cube['stand'] = cube['provenance'].split('hat am')[-1].split(
            'um')[0].strip()
        cubes.append(cube)
    common = [d for d, i in list(dims.items()) if i == len(cubes)]
    commons = {}
    for cube in cubes:
        for dim in cube['dimensions']:
            if dim['dim_name'] in common and dim['show']:
                #dim['show'] = False
                commons[dim['dim_name']] = dim

    keywords = make_keywords(titles)
    description = desc.get('method', '')[:150]
    return render_template('statistic/view.html',
                           catalog=catalog,
                           desc=desc,
                           cubes=cubes,
                           keywords_text=keywords,
                           description_text=description,
                           common=list(commons.values()),
                           has_common=len(common) > 0,
                           statistic=statistic)
Ejemplo n.º 5
0
def generate_cubes():
    cubes = []
    for cube in get_cubes():
        dimensions = []
        measures = []
        joins = []
        mappings = {}
        cube_name = cube.get('cube_name')
        for dim in get_dimensions(cube_name):
            dn = dim.get('dim_name')
            if dim.get('dim_measure_type').startswith('W-'):
                measures.append(dn)
                continue

            dimensions.append(dn)
            if dim.get('dim_measure_type').startswith('ZI-'):
                mappings[dn + '.text'] = 'fact_%s.%s' % (cube_name, dn)
                mappings[dn + '.from'] = 'fact_%s.%s_from' % (cube_name, dn)
                mappings[dn + '.until'] = 'fact_%s.%s_until' % (cube_name, dn)
            else:
                tn = 'tbl_' + dn
                joins.append({
                    'master': dn,
                    'detail': 'value.value_id',
                    'alias': tn
                })
                mappings[dn + '.name'] = tn + '.name'
                mappings[dn + '.label'] = tn + '.title_de'

        cubes.append({
            'dimensions': dimensions,
            'measures': measures,
            'mappings': mappings,
            'joins': joins,
            'fact': 'fact_%s' % cube_name,
            'name': cube.get('cube_name'),
            'label': cube.get('statistic_title_de'),
            'description': cube.get('statistic_description_de'),
        })
    return cubes
Ejemplo n.º 6
0
def view(catalog, slug, name):
    catalog = get_catalog(catalog)
    statistic = statistic_table.find_one(name=name)
    desc = parse_description(statistic['description_de'] or '')
    cubes = []
    dims = defaultdict(int)
    titles = set([statistic['title_de']])
    for cube in get_cubes(name):
      cube['dimensions'] = get_dimensions(cube['name'])
      for dim in cube['dimensions']:
        dim['show'] = True
        dims[dim['dim_name']] += 1
        titles.add(dim['dim_title_de'])
        dim['type_text'] = dimension_type_text(dim['dim_measure_type'])
        if dim['dim_measure_type'].startswith('K-REG'):
            cube['admlevel'] = (ADM_RANKS[dim['dim_name']], dim['dim_title_de'], dim['dim_name'])
            dim['show'] = False
      cube['stand'] = cube['provenance'].split('hat am')[-1].split('um')[0].strip()
      cubes.append(cube)
    common = [d for d, i in dims.items() if i == len(cubes)]
    commons = {}
    for cube in cubes:
        for dim in cube['dimensions']:
            if dim['dim_name'] in common and dim['show']:
                #dim['show'] = False
                commons[dim['dim_name']] = dim

    keywords = make_keywords(titles)
    description = desc.get('method', '')[:150]
    return render_template('statistic/view.html',
                           catalog=catalog,
                           desc=desc,
                           cubes=cubes,
                           keywords_text=keywords,
                           description_text=description,
                           common=commons.values(),
                           has_common=len(common) > 0,
                           statistic=statistic)