Exemplo n.º 1
0
def search_by_keyword(_, resp: responder.Response, keyword: str):
    movies = db.search_keyword(keyword)
    limited = len(movies) > response_count_max
    if limited:
        movies = movies[:response_count_max]
    movie_dicts = [db.movie_to_dict(m) for m in movies]
    resp.media = {
        "keyword": keyword,
        "hits": movie_dicts,
        "truncated_results": limited
    }
Exemplo n.º 2
0
def search_keyword(req, resp, keyword: str):
    movies = db.search_keyword(keyword)
    print("Searching for {}, {} results".format(keyword, len(movies)))

    limited = len(movies) > response_count_max
    if limited:
        movies = movies[:response_count_max]

    movie_dicts = [
        db.movie_to_dict(m)
        for m in movies
    ]

    resp.media = {'keyword': keyword, 'hits': movie_dicts, 'truncated_results': limited}
Exemplo n.º 3
0
def search_by_keyword(_, resp: responder.Response, keyword: str):
    movies = db.search_keyword(keyword)
    print("Searching for movie by keyword: {}".format(keyword))

    limited = len(movies) > response_count_max
    if limited:
        movies = movies[:10]

    movie_dicts = [
        db.movie_to_dict(m)
        for m in movies
    ]

    resp.media = {'keyword': keyword, 'hits': movie_dicts, 'truncated_results': limited}
Exemplo n.º 4
0
def search_by_keyword(_, response: responder.Response, keyword: str) -> None:
    movies = db.search_keyword(keyword)

    # Limit returns. Why ever... The limit seems arbitrary.
    max_returns = 10
    if len(movies) > max_returns:
        movies = movies[:max_returns]

    movie_dicts = [db.movie_to_dict(movie) for movie in movies]

    response.media = {
        "Searched": keyword,
        "Found": len(movie_dicts),
        "Results": movie_dicts,
    }
def search_by_keyword(_, resp: responder.Response, keyword: str):
    movies = db.search_keyword(keyword)
    print(f"Searching for movies by keyword: {keyword}")

    limited = len(movies) > RESPONSE_COUNT_MAX
    if limited:
        movies = movies[:10]

    movie_dicts = [db.movie_to_dict(m) for m in movies]

    resp.media = {
        "keyword": keyword,
        "hits": movie_dicts,
        "truncated_results": limited
    }
Exemplo n.º 6
0
def search(req, resp, keyword: str):
    # search the database using the supplied keyword
    movies = db.search_keyword(keyword)

    # set the media property to indicate JSON
    resp.media = {"keyword": keyword, "result": movies}