Remove ability to filter album by artist, go via getArtist instead

This commit is contained in:
simojenki
2021-03-07 09:20:06 +11:00
parent c5a085d667
commit 3f607c5304
3 changed files with 9 additions and 99 deletions

View File

@@ -23,9 +23,6 @@ import {
type P<T> = (t: T) => boolean;
const all: P<any> = (_: any) => true;
const albumByArtist = (id: string): P<[Artist, Album]> => ([artist, _]) =>
artist.id === id;
const albumWithGenre = (genre: string): P<[Artist, Album]> => ([_, album]) =>
album.genre === genre;
@@ -75,10 +72,8 @@ export class InMemoryMusicService implements MusicService {
.flatMap((artist) => artist.albums.map((album) => [artist, album]))
.filter(
pipe(
pipe(O.fromNullable(q.artistId), O.map(albumByArtist)),
O.alt(() =>
pipe(O.fromNullable(q.genre), O.map(albumWithGenre))
),
O.fromNullable(q.genre),
O.map(albumWithGenre),
O.getOrElse(() => all)
)
)