def get_all_movies(repo: AbstractRepository): movies = repo.get_all_movies() movies_dto = list() if len(movies) > 0: movies_dto = movies_to_dict(movies) return movies_dto
def get_page_items_movies_search(search_query: str, match_threshold: float, current_page_num: int, results_per_page: int, repo: AbstractRepository): search_result_set = [] for movie in repo.get_all_movies(): movie_str = build_movie_string(movie) tk_set_ratio = token_set_ratio(search_query, movie_str) if tk_set_ratio > match_threshold: search_result_set.append((tk_set_ratio, movie)) search_result_set.sort(reverse=True) movies_obj_tuple_list, prev_page, next_page = get_page_items(current_page_num, results_per_page, search_result_set) number_pages = get_number_pages(results_per_page, len(search_result_set)) number_results = len(search_result_set) return search_tuple_to_movies_dict(movies_obj_tuple_list), prev_page, next_page, number_pages, number_results