def fetchcube(catalog_name, cube_name): """ Dump a single cube from a catalog. """ catalog = get_catalog(catalog_name) cube_data = fetch_cube(catalog, cube_name) if cube_data is None: log.warn("Could not fetch: %s", cube_name) else: store_cube_raw(catalog_name, cube_name, cube_data)
def fetchcube(catalog_name, cube_name): """ Dump a single cube from a catalog. """ catalog = get_catalog(catalog_name) cube_data = fetch_cube(catalog, cube_name) if cube_data is None: log.warn("Could not fetch: %s", cube_name) else: store_cube_raw(catalog_name, cube_name, cube_data)
def load(catalog_name, update=False): """ Load all cubes into a database. """ catalog = get_catalog(catalog_name) for cube_name in fetch_index(catalog): if exists_raw(catalog_name, cube_name): cube_data = load_cube_raw(catalog_name, cube_name) cube = Cube(cube_name, cube_data) log.info("Loading: %s (%s facts)", cube_name, len(cube.facts)) load_cube(cube, update=update)
def load(catalog_name, update=False): """ Load all cubes into a database. """ catalog = get_catalog(catalog_name) for cube_name in fetch_index(catalog): if exists_raw(catalog_name, cube_name): cube_data = load_cube_raw(catalog_name, cube_name) cube = Cube(cube_name, cube_data) log.info("Loading: %s (%s facts)", cube_name, len(cube.facts)) load_cube(cube, update=update)
def view(catalog): catalog = get_catalog(catalog) statistics = statistic_table.find(order_by='title_de') dimensions = [] for dimension in dimension_table.find(order_by='title_de'): dimension['measure_type_name'] = dimension_type_text(dimension['measure_type']) dimensions.append(dimension) return render_template('catalog/index.html', catalog=catalog, statistics=statistics, dimensions=dimensions)
def view(catalog, name): catalog = get_catalog(catalog) dimension = dimension_table.find_one(name=name) values = list(value_table.find(dimension_name=name, order_by='title_de')) has_values = len(values) > 0 statistics = get_statistics(name) return render_template('dimension/view.html', catalog=catalog, statistics=statistics, values=values, has_values=has_values, dimension=dimension)
def view(catalog, name): catalog = get_catalog(catalog) dimension = dimension_table.find_one(name=name) values = list(value_table.find(dimension_name=name, order_by='title_de')) has_values = len(values) > 0 statistics = get_statistics(name) return render_template('dimension/view.html', catalog=catalog, statistics=statistics, values=values, has_values=has_values, dimension=dimension)
def view(catalog): catalog = get_catalog(catalog) statistics = statistic_table.find(order_by='title_de') dimensions = [] for dimension in dimension_table.find(order_by='title_de'): dimension['measure_type_name'] = dimension_type_text( dimension['measure_type']) dimensions.append(dimension) return render_template('catalog/index.html', catalog=catalog, statistics=statistics, dimensions=dimensions)
def fetch(catalog_name, update=False): """ Dump all cubes from a catalog. """ catalog = get_catalog(catalog_name) for cube_name in fetch_index(catalog): if not exists_raw(catalog_name, cube_name) or update: log.info("Fetching: %s", cube_name) try: cube_data = fetch_cube(catalog, cube_name) if cube_data is None: log.warn("Could not fetch: %s", cube_name) else: store_cube_raw(catalog_name, cube_name, cube_data) except Exception as e: log.exception(e)
def fetch(catalog_name, update=False): """ Dump all cubes from a catalog. """ catalog = get_catalog(catalog_name) for cube_name in fetch_index(catalog): if not exists_raw(catalog_name, cube_name) or update: log.info("Fetching: %s", cube_name) try: cube_data = fetch_cube(catalog, cube_name) if cube_data is None: log.warn("Could not fetch: %s", cube_name) else: store_cube_raw(catalog_name, cube_name, cube_data) except Exception, e: log.exception(e)
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)
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)