Exemple #1
0
def providers_datasets_list(provider):
    provider_doc = queries.get_provider(provider)
    query = {'provider_name': provider_doc["name"]}
    projection = {
        "_id": False,
        "tags": False,
        "enable": False,
        "lock": False,
        "concepts": False,
        "codelists": False
    }
    #docs = [doc for doc in queries.col_datasets().find(query, projection)]
    docs = queries.col_datasets().find(query, projection)

    page = request.args.get('page', default=1, type=int)
    per_page = request.args.get('per_page', default=10, type=int)
    if per_page > 50:
        per_page = 50
    pagination = queries.Pagination(docs, page, per_page)
    meta = {
        "page": pagination.page,
        "pages": pagination.pages,
        "per_page": pagination.per_page,
        "total": pagination.total,
    }
    _docs = [doc for doc in pagination.items]
    #return json_tools.json_response(_docs, meta=meta)
    return json_tools.json_response_async(_docs, meta=meta)
Exemple #2
0
def dataset_series_list_values(dataset):

    query = {'enable': True, 'slug': dataset}
    projection = {"_id": False, "provider_name": True, "dataset_code": True }
    doc = queries.col_datasets().find_one(query, projection)
    if not doc:
        abort(404)
        
    query = {"provider_name": doc["provider_name"], 
             'dataset_code': doc["dataset_code"]}
    projection = {
        "_id": False, 
        "key": True, "slug": True, 
        "name": True, "frequency": True,
        "start_date": True, "end_date": True,
        "dimensions": True, "attributes": True,
        "values.value": True, "values.period": True,
    }

    query = queries.complex_queries_series(query)
    docs = queries.col_series().find(query, projection)

    page = request.args.get('page', default=1, type=int)
    per_page = request.args.get('per_page', default=50, type=int)
    if per_page > 1000:
        per_page = 1000
    pagination = queries.Pagination(docs, page, per_page)
    meta = {
        "page": pagination.page,
        "pages": pagination.pages,
        "per_page": pagination.per_page,
        "total": pagination.total,
    }
    _docs = [doc for doc in pagination.items]
    return json_tools.json_response_async(_docs, meta=meta)
Exemple #3
0
def dataset_series_list_values(dataset):

    query = {'enable': True, 'slug': dataset}
    projection = {"_id": False, "provider_name": True, "dataset_code": True}
    doc = queries.col_datasets().find_one(query, projection)
    if not doc:
        abort(404)

    query = {
        "provider_name": doc["provider_name"],
        'dataset_code': doc["dataset_code"]
    }
    projection = {
        "_id": False,
        "key": True,
        "slug": True,
        "name": True,
        "frequency": True,
        "start_date": True,
        "end_date": True,
        "dimensions": True,
        "attributes": True,
        "values.value": True,
        "values.period": True,
    }

    query = queries.complex_queries_series(query)
    docs = queries.col_series().find(query, projection)

    page = request.args.get('page', default=1, type=int)
    per_page = request.args.get('per_page', default=50, type=int)
    if per_page > 1000:
        per_page = 1000
    pagination = queries.Pagination(docs, page, per_page)
    meta = {
        "page": pagination.page,
        "pages": pagination.pages,
        "per_page": pagination.per_page,
        "total": pagination.total,
    }
    _docs = [doc for doc in pagination.items]
    return json_tools.json_response_async(_docs, meta=meta)
Exemple #4
0
def providers_datasets_list(provider):
    provider_doc = queries.get_provider(provider)
    query = {'provider_name': provider_doc["name"]}
    projection = {"_id": False, "tags": False,
                  "enable": False, "lock": False,
                  "concepts": False, "codelists": False}
    #docs = [doc for doc in queries.col_datasets().find(query, projection)]
    docs = queries.col_datasets().find(query, projection)
    
    page = request.args.get('page', default=1, type=int)
    per_page = request.args.get('per_page', default=10, type=int)
    if per_page > 50:
        per_page = 50
    pagination = queries.Pagination(docs, page, per_page)
    meta = {
        "page": pagination.page,
        "pages": pagination.pages,
        "per_page": pagination.per_page,
        "total": pagination.total,
    }
    _docs = [doc for doc in pagination.items]
    #return json_tools.json_response(_docs, meta=meta)
    return json_tools.json_response_async(_docs, meta=meta)