Ejemplo n.º 1
0
    def get_shortest_serials_in_genres(cls, genres_list: List[str]):

        query_result = qe.execute_arbitrary(db_engine,
                                             "SELECT *"
                                             " FROM get_shortest_serials_in_genres({genres_list})",
                                            **{
                                                "genres_list": qh.get_sql_array(genres_list)
                                            })

        return [{"serial_title": str(row['serial_title']).rstrip(),
                 "duration": row['serial_duration']}
                for row in query_result]
Ejemplo n.º 2
0
    def get_filtered_serials(cls, title_part: str, start_year: int,
                             end_year: int, start_rating: int, end_rating: int,
                             countries_list: List[str], actors_list: List[str],
                             genres_list: List[str], start_duration: int,
                             end_duration: int) -> List[Serial]:
        """
        Get serials filtered by given params
        :param start_duration:
        :param end_duration:
        :param title_part:
        :param end_rating:
        :param start_rating:
        :param actors_list:
        :param genres_list:
        :param start_year: start year of the serials
        :param end_year: end year of the serials
        :param countries_list: list of the countries from wich serials needed
        :return: list of serials
        """
        serials_columns_string = qh.get_columns_string(SerialsMapping)

        all_serials_query = qe.execute_mapped(
            db, "SELECT {serials_columns}"
            " FROM get_filtered_serials('{title_part}', {start_year}, "
            " {end_year}, {start_rating}, {end_rating}, {countries}, {actors}, {genres},"
            " {start_duration}, {end_duration})", *[Serial], **{
                'serials_columns': serials_columns_string,
                'title_part': title_part,
                'start_year': start_year,
                'end_year': end_year,
                'start_rating': start_rating,
                'end_rating': end_rating,
                'countries': qh.get_sql_array(countries_list),
                'actors': qh.get_sql_array(actors_list),
                'genres': qh.get_sql_array(genres_list),
                'start_duration': start_duration,
                'end_duration': end_duration
            })

        return cls._get_extended_serials(all_serials_query)