def handle_list_releases(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=ReleaseIncludes.parse) release_group_query = g.db.query(ReleaseGroup.id).filter_by(gid=gid).as_scalar() query = query_release(g.db, include).\ filter(Release.release_group_id == release_group_query).\ order_by(Release.id).limit(10) # FIXME releases_data = [] for release in query: releases_data.append(serialize_release(release, include)) return response_ok(releases=releases_data)
def handle_get(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=ReleaseIncludes.parse) if include.artist and include.artists: abort(response_error(INCLUDE_DEPENDENCY_ERROR, 'include=artist and include=artists are mutually exclusive')) release = get_release_by_gid(query_release(g.db, include), gid) if release is None: abort(response_error(NOT_FOUND_ERROR, 'release not found')) if include.relationships: load_links(g.db, [release], include.relationships) return response_ok(release=serialize_release(release, include))
def handle_list_releases(): gid = get_param('id', type='uuid', required=True) include = get_param('include', type='enum+', container=ReleaseIncludes.parse) artist = get_plain_artist_by_gid_or_error(gid) artist_credits_query = g.db.query(ArtistCreditName.artist_credit_id).\ filter_by(artist_id=artist.id) query = query_release(g.db, include).\ filter(Release.artist_credit_id.in_(artist_credits_query)).\ order_by(Release.id).limit(10) # FIXME releases_data = [] for release in query: releases_data.append(serialize_release(release, include)) return response_ok(releases=releases_data)