Esempio n. 1
0
def welcome():
    """
    landing page with welcome message
    :return:
    """
    if request.method == 'POST':
        if len(request.form) == 2:
            return do_single_search(request.form)
        elif len(request.form) == 3:
            return do_double_search(request.form)

    else:
        totals = perform_query({"query": "*:*",
                                "facet": {"country": terms_facet("country_s")}})["facets"]['country']["buckets"]
        country_totals = {country_info['val']: country_info['count'] for country_info in totals}
        # country_totals = {country_info[1]: totals[totals.country_code == country_info[1]].sum()['num_docs'].sum() for
        #                   country_info in AVAILABLE_OPTIONS}

        return flask.render_template('index.html', map_views=MAP_VIEWS,
                                     available_options=AVAILABLE_OPTIONS,
                                     totals=country_totals)
Esempio n. 2
0
def search():
    """
    Displays the search page accessible at '/search'
    """
    if request.method == 'POST':
        if len(request.form) == 2:
            return do_single_search(request.form)
        elif len(request.form) == 3:
            return do_double_search(request.form)

    else:
        totals = perform_query({"query": "*:*",
                                "facet": {"country": terms_facet("country_s")}})["facets"]['country']["buckets"]
        country_totals = {country_info['val']: country_info['count'] for country_info in totals}
        # totals = simple_query_totals()
        # country_totals = {country_info[1]: totals[totals.country_code == country_info[1]].sum()['num_docs'].sum() for
        #                   country_info in AVAILABLE_OPTIONS}

        return flask.render_template('search.html',
                                     map_views=MAP_VIEWS,
                                     available_options=AVAILABLE_OPTIONS,
                                     totals=country_totals)