Exemple #1
0
def make_views():
    for cube in get_cubes():
        slug = slugify(cube.get('statistic_title_de'))
        slug = slug.replace('-', '_')
        slug = slug + '_' + cube.get('cube_name')
        q = 'DROP VIEW IF EXISTS ' + slug
        engine.query(q)
        q, params = query_cube(cube.get('cube_name'), readable=False)
        q = 'CREATE VIEW ' + slug + ' AS ' + unicode(q)
        engine.query(q, **params)
        print [slug, q]
Exemple #2
0
def freeze_data():
    print "Freezing dimension values..."
    prefix = os.path.join(get_output_dir(), 'data', 'dimensions')
    freeze(value_table.all(), prefix=prefix, filename='{{dimension_name}}.csv', format='csv')
    freeze(value_table.all(), prefix=prefix, filename='{{dimension_name}}.json', format='json')

    print "Freezing cubes..."
    for cube in get_cubes():
        prefix = os.path.join(get_output_dir(), 'data',
                              cube['statistic_name'],
                              cube['cube_name'])
        slug = slugify(cube['statistic_title_de'])
        for (text, rb) in [('labeled', True), ('raw', False)]:
            q, ps = query_cube(cube['cube_name'], readable=rb)
            fn = '%s-%s-%s.csv' % (slug, cube['cube_name'], text)
            print [fn]
            freeze(engine.query(q), prefix=prefix, filename=fn)
Exemple #3
0
def freeze_html():
    print "Copying /static..."
    outdir = os.path.join(get_output_dir(), 'static')
    if os.path.isdir(outdir):
        shutil.rmtree(outdir)
    shutil.copytree(app.static_folder, outdir)
    freeze_request('/index.html')
    freeze_request('/faq.html')
    freeze_request('/api.html')
    freeze_request('/contact.html')
    for catalog in ['regional']:
        freeze_request('/%s/index.html' % catalog)
        for dimension in get_all_dimensions():
            freeze_request('/%s/dimensions/%s.html' % (catalog, dimension['name']))
        for statistic in get_all_statistics():
            slug = slugify(statistic['title_de'])
            freeze_request('/%s/statistics/%s.%s.html' % (catalog, slug, statistic['name']))