Пример #1
0
def show_search_results(go_button_n_clicks, dropdown_value, search_text):
    """
    Determine what kind of results to show from the search text, search type,
    and number of clicks of the search button. Cache if necessary using flask.

    Args:
        go_button_n_clicks (int): The number of clicks of the "Go" button.
        dropdown_value (str): The type of search to execute.
        search_text (str): The raw search text as entered in the search field.

    Returns:
        (dash_html_components.Div): The correct html block for the search type
            and customized according to search results from the search text.
    """
    if search_text:
        # Prevent from caching on n_clicks if the results aren"t empty
        @cache.memoize(timeout=cache_timeout)
        def memoize_wrapper(dropdown_value, search_text):
            return sl.show_search_results(go_button_n_clicks, dropdown_value,
                                          search_text)

        return memoize_wrapper(dropdown_value, search_text)
    else:
        return sl.show_search_results(go_button_n_clicks, dropdown_value,
                                      search_text)
Пример #2
0
 def memoize_wrapper(dropdown_value, search_text):
     return sl.show_search_results(go_button_n_clicks, dropdown_value,
                                   search_text)