def __get_years_(search_year, start, step) -> list: """ get years (like ids) from search information :param search_year: search information :param start: the start row :param step: number of rows :return: years (like ids) """ sql_request = _sql_request_search_years(search_year) years = get_ids_by_request(sql_request, start, step) return years
def __get_songs_ids_hit_several_times(content, start, step) -> list: """ Getting ids of songs that hit billboard several times and also add to content a sort information :param content: dictionary that contain the type and value of searching :param start: the start row :param step: number of rows :return: list ids of songs that hit billboard several times """ sql_request = sql_request_songs.sql_request_songs_hit_several_times() content['order'] = 'order by billboard.id_song, artist.id_artist' ids = get_ids_by_request(sql_request, start, step) return ids
def __get_artists_ids_group(content: dict, start: int, step: int) -> list: """ Get ids of groups and add to content a sort information :param content: dictionary that contain the type and value of searching :param start: the start row :param step: number of rows :return: list ids of dead artists """ sql_request = sql_request_artists_group() content['order'] = 'order by artist.id_artist' ids = get_ids_by_request(sql_request, start, step) return ids
def __get_artists_ids_by_name(content: dict, start: int, step: int) -> list: """ Get ids of artists by the name artist and add to content a sort information :param content: dictionary that contain the type and value of searching :param start: the start row :param step: number of rows :return: list ids of artists by name """ sql_request = sql_request_artists_by_name(content['value']) content['order'] = '' ids = get_ids_by_request(sql_request, start, step) return ids
def __get_songs_ids_by_artist(content, start, step) -> list: """ Getting ids of songs by performer artist name and add to content a sort information :param content: dictionary that contain the type and value of searching :param start: the start row :param step: number of rows :return: list ids of songs by year """ sql_request = sql_request_songs.sql_request_songs_by_artist( content['value']) content['order'] = 'order by billboard.position, artist.id_artist' ids = get_ids_by_request(sql_request, start, step) return ids
def __get_songs_ids_by_year(content, start, step) -> list: """ Getting ids of songs by year's of getting at billboard and add to content a sort information :param content: dictionary that contain the type and value of searching :param start: the start row :param step: number of rows :return: list ids of songs by year """ sql_request = sql_request_songs.sql_request_songs_by_year(content['value']) content['order'] = " order by case when year = '"+content['value']+\ "' then '1' else billboard.year end, billboard.position" ids = get_ids_by_request(sql_request, start, step) return ids
def get_years_genre(id_genre) -> dict: """ get years that has song with current genre :param id_genre: current genre :return: tuple years data """ # It's look strange, but it's fine, probably sql_request = _sql_request_years_genre(id_genre) sql_data = get_data_from_db(sql_request) years_list = get_ids_by_request(sql_request) years_data = get_years_list(years_list) years = create_years_genre(sql_data, years_data) return years
def sql_request_featuring_artists(id_artist) -> str: """ Complex request At first it here need to get ids of songs by artist and then construct request :param id_artist: id of artist :return: str request """ id_songs = get_ids_by_request(sql_request_songs_artist_ids(id_artist)) sql_request = """ SELECT DISTINCT artist.id_artist, artist.name_artist, artist.image_artist FROM song LEFT JOIN song_performers ON (song_performers.id_song = song.id_song) LEFT JOIN artist ON (song_performers.id_artist = artist.id_artist) WHERE not artist.id_artist = """ + str(id_artist) sql_request += ' and (song.id_song = 0' for id_song in id_songs: sql_request += ' or song.id_song =' + str(id_song) sql_request += ') GROUP BY artist.id_artist ' return sql_request