{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module WikiMusic.Sqlite.SongQuery () where
import Data.Map (elems, keys)
import Data.Map qualified as Map
import Data.UUID
import Data.UUID qualified as UUID
import Database.Beam
import Database.Beam.Sqlite
import Free.AlaCarte
import Optics
import Relude
import WikiMusic.Beam.Artist
import WikiMusic.Beam.Database
import WikiMusic.Beam.Song
import WikiMusic.Beam.Util
import WikiMusic.Free.SongQuery
import WikiMusic.Model.Env
import WikiMusic.Model.Other
import WikiMusic.Model.Song
import WikiMusic.Model.Thread as CommentThread
instance Exec SongQuery where
execAlgebra :: forall a. SongQuery (IO a) -> IO a
execAlgebra (FetchSongs Env
env SongSortOrder
sortOrder Limit
limit Offset
offset (Map UUID Song, [UUID]) -> IO a
next) =
(Map UUID Song, [UUID]) -> IO a
next ((Map UUID Song, [UUID]) -> IO a)
-> IO (Map UUID Song, [UUID]) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env
-> SongSortOrder -> Limit -> Offset -> IO (Map UUID Song, [UUID])
forall (m :: * -> *).
MonadIO m =>
Env
-> SongSortOrder -> Limit -> Offset -> m (Map UUID Song, [UUID])
fetchSongs' Env
env SongSortOrder
sortOrder Limit
limit Offset
offset
execAlgebra (FetchSongsByUUID Env
env SongSortOrder
sortOrder [UUID]
identifiers (Map UUID Song, [UUID]) -> IO a
next) =
(Map UUID Song, [UUID]) -> IO a
next ((Map UUID Song, [UUID]) -> IO a)
-> IO (Map UUID Song, [UUID]) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env -> SongSortOrder -> [UUID] -> IO (Map UUID Song, [UUID])
forall (m :: * -> *).
MonadIO m =>
Env -> SongSortOrder -> [UUID] -> m (Map UUID Song, [UUID])
fetchSongsByUUID' Env
env SongSortOrder
sortOrder [UUID]
identifiers
execAlgebra (EnrichedSongResponse Env
env Map UUID Song
songMap EnrichSongParams
enrichSongParams Map UUID Song -> IO a
next) = Map UUID Song -> IO a
next (Map UUID Song -> IO a) -> IO (Map UUID Song) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env -> Map UUID Song -> EnrichSongParams -> IO (Map UUID Song)
forall (m :: * -> *).
MonadIO m =>
Env -> Map UUID Song -> EnrichSongParams -> m (Map UUID Song)
enrichedSongResponse' Env
env Map UUID Song
songMap EnrichSongParams
enrichSongParams
execAlgebra (FetchSongComments Env
env [UUID]
identifiers Map UUID SongComment -> IO a
next) =
Map UUID SongComment -> IO a
next (Map UUID SongComment -> IO a) -> IO (Map UUID SongComment) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env -> [UUID] -> IO (Map UUID SongComment)
forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m (Map UUID SongComment)
fetchSongComments' Env
env [UUID]
identifiers
execAlgebra (FetchSongOpinions Env
env [UUID]
identifiers Map UUID SongOpinion -> IO a
next) =
Map UUID SongOpinion -> IO a
next (Map UUID SongOpinion -> IO a) -> IO (Map UUID SongOpinion) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env -> [UUID] -> IO (Map UUID SongOpinion)
forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m (Map UUID SongOpinion)
fetchSongOpinions' Env
env [UUID]
identifiers
execAlgebra (FetchSongArtworks Env
env [UUID]
identifiers Map UUID SongArtwork -> IO a
next) =
Map UUID SongArtwork -> IO a
next (Map UUID SongArtwork -> IO a) -> IO (Map UUID SongArtwork) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env -> [UUID] -> IO (Map UUID SongArtwork)
forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m (Map UUID SongArtwork)
fetchSongArtworks' Env
env [UUID]
identifiers
execAlgebra (FetchSongArtists Env
env [UUID]
identifiers [(UUID, UUID, Text)] -> IO a
next) = [(UUID, UUID, Text)] -> IO a
next ([(UUID, UUID, Text)] -> IO a) -> IO [(UUID, UUID, Text)] -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env -> [UUID] -> IO [(UUID, UUID, Text)]
forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m [(UUID, UUID, Text)]
fetchSongArtists' Env
env [UUID]
identifiers
execAlgebra (SearchSongs Env
env SearchInput
searchInput SongSortOrder
sortOrder Limit
limit Offset
offset (Map UUID Song, [UUID]) -> IO a
next) = (Map UUID Song, [UUID]) -> IO a
next ((Map UUID Song, [UUID]) -> IO a)
-> IO (Map UUID Song, [UUID]) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env
-> SearchInput
-> SongSortOrder
-> Limit
-> Offset
-> IO (Map UUID Song, [UUID])
forall (m :: * -> *).
MonadIO m =>
Env
-> SearchInput
-> SongSortOrder
-> Limit
-> Offset
-> m (Map UUID Song, [UUID])
searchSongs' Env
env SearchInput
searchInput SongSortOrder
sortOrder Limit
limit Offset
offset
execAlgebra (FetchSongContents Env
env [UUID]
identifiers Map UUID SongContent -> IO a
next) =
Map UUID SongContent -> IO a
next (Map UUID SongContent -> IO a) -> IO (Map UUID SongContent) -> IO a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Env -> [UUID] -> IO (Map UUID SongContent)
forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m (Map UUID SongContent)
fetchSongContents' Env
env [UUID]
identifiers
mkOrderBy :: SongSortOrder
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
mkOrderBy SongSortOrder
AscCreatedAt = (a -> QOrd be s a)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QExpr be s a -> QOrd be s a
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
asc_ (QExpr be s a -> QOrd be s a)
-> (a -> QExpr be s a) -> a -> QOrd be s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Optic' k NoIx a (QExpr be s a) -> QExpr be s a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx a (QExpr be s a)
#createdAt))
mkOrderBy SongSortOrder
DescCreatedAt = (a -> QOrd be s a)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QExpr be s a -> QOrd be s a
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
desc_ (QExpr be s a -> QOrd be s a)
-> (a -> QExpr be s a) -> a -> QOrd be s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Optic' k NoIx a (QExpr be s a) -> QExpr be s a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx a (QExpr be s a)
#createdAt))
mkOrderBy SongSortOrder
AscDisplayName = (a -> QOrd be s a)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QExpr be s a -> QOrd be s a
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
asc_ (QExpr be s a -> QOrd be s a)
-> (a -> QExpr be s a) -> a -> QOrd be s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Optic' k NoIx a (QExpr be s a) -> QExpr be s a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx a (QExpr be s a)
#displayName))
mkOrderBy SongSortOrder
DescDisplayName = (a -> QOrd be s a)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QExpr be s a -> QOrd be s a
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
desc_ (QExpr be s a -> QOrd be s a)
-> (a -> QExpr be s a) -> a -> QOrd be s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Optic' k NoIx a (QExpr be s a) -> QExpr be s a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx a (QExpr be s a)
#displayName))
mkOrderBy SongSortOrder
AscLastEditedAt = (a -> QOrd be s a)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QExpr be s a -> QOrd be s a
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
asc_ (QExpr be s a -> QOrd be s a)
-> (a -> QExpr be s a) -> a -> QOrd be s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Optic' k NoIx a (QExpr be s a) -> QExpr be s a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx a (QExpr be s a)
#lastEditedAt))
mkOrderBy SongSortOrder
DescLastEditedAt = (a -> QOrd be s a)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QExpr be s a -> QOrd be s a
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
desc_ (QExpr be s a -> QOrd be s a)
-> (a -> QExpr be s a) -> a -> QOrd be s a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Optic' k NoIx a (QExpr be s a) -> QExpr be s a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx a (QExpr be s a)
#lastEditedAt))
fetchSongs' :: (MonadIO m) => Env -> SongSortOrder -> Limit -> Offset -> m (Map UUID Song, [UUID])
fetchSongs' :: forall (m :: * -> *).
MonadIO m =>
Env
-> SongSortOrder -> Limit -> Offset -> m (Map UUID Song, [UUID])
fetchSongs' Env
env SongSortOrder
sortOrder (Limit Int
limit) (Offset Int
offset) = do
[Song']
songs <-
IO [Song'] -> m [Song']
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO [Song'] -> m [Song']) -> IO [Song'] -> m [Song']
forall a b. (a -> b) -> a -> b
$ (String -> IO ()) -> Connection -> SqliteM [Song'] -> IO [Song']
forall a. (String -> IO ()) -> Connection -> SqliteM a -> IO a
runBeamSqliteDebug String -> IO ()
forall (m :: * -> *). MonadIO m => String -> m ()
putStrLn (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM [Song'] -> IO [Song']) -> SqliteM [Song'] -> IO [Song']
forall a b. (a -> b) -> a -> b
$ SqlSelect Sqlite Song' -> SqliteM [Song']
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect Sqlite Song' -> SqliteM [Song'])
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqlSelect Sqlite Song')
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqliteM [Song']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> SqlSelect
Sqlite
(QExprToIdentity
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> SqlSelect Sqlite Song'
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> SqlSelect Sqlite Song')
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqlSelect Sqlite Song'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
forall s a be (db :: (* -> *) -> *).
(Projectible be a, ThreadRewritable (QNested s) a) =>
Integer
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
limit_ (Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
limit)
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
forall s a be (db :: (* -> *) -> *).
(Projectible be a, ThreadRewritable (QNested s) a) =>
Integer
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
offset_ (Int -> Integer
forall a. Integral a => a -> Integer
toInteger Int
offset)
(Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SongSortOrder
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(WithRewrittenThread
(QNested (QNested (QNested QBaseScope)))
(QNested (QNested QBaseScope))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope))))))
forall {be} {a} {s} {k} {k} {k} {s} {a} {s} {a} {s} {a}
{db :: (* -> *) -> *}.
(Sql92OrderingExpressionSyntax
(Sql92SelectOrderingSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92TableSourceExpressionSyntax
(Sql92FromTableSourceSyntax
(Sql92SelectTableFromSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92GroupingExpressionSyntax
(Sql92SelectTableGroupingSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92ExpressionSelectSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
~ Sql92SelectSyntax (BeamSqlBackendSyntax be),
Sql92ProjectionExpressionSyntax
(Sql92SelectTableProjectionSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92InsertValuesExpressionSyntax
(Sql92InsertValuesSyntax
(Sql92InsertSyntax (BeamSqlBackendSyntax be)))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92FromExpressionSyntax
(Sql92SelectTableFromSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92UpdateFieldNameSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
~ Sql92ExpressionFieldNameSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
ProjectibleWithPredicate
AnyType
be
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
a,
ThreadRewritable (QNested s) a, BeamSqlBackend be, Is k A_Getter,
Is k A_Getter, Is k A_Getter,
LabelOptic "createdAt" k a a (QExpr be s a) (QExpr be s a),
LabelOptic "lastEditedAt" k a a (QExpr be s a) (QExpr be s a),
LabelOptic "displayName" k a a (QExpr be s a) (QExpr be s a),
IsSql92AggregationExpressionSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
Eq
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
HasSqlValueSyntax
(Sql92ExpressionValueSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
SqlNull) =>
SongSortOrder
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
mkOrderBy SongSortOrder
sortOrder
(Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqliteM [Song'])
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqliteM [Song']
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
-> DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
#songs) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
Env -> [Song'] -> m (Map UUID Song, [UUID])
forall (m :: * -> *).
MonadIO m =>
Env -> [Song'] -> m (Map UUID Song, [UUID])
filledSongs Env
env [Song']
songs
fetchSongsByUUID' :: (MonadIO m) => Env -> SongSortOrder -> [UUID] -> m (Map UUID Song, [UUID])
fetchSongsByUUID' :: forall (m :: * -> *).
MonadIO m =>
Env -> SongSortOrder -> [UUID] -> m (Map UUID Song, [UUID])
fetchSongsByUUID' Env
env SongSortOrder
sortOrder [UUID]
identifiers = do
[Song']
songs <-
IO [Song'] -> m [Song']
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO [Song'] -> m [Song'])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO [Song'])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [Song']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> SqliteM [Song'] -> IO [Song']
forall a. Connection -> SqliteM a -> IO a
runBeamSqlite (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM [Song'] -> IO [Song'])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM [Song'])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO [Song']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SqlSelect Sqlite Song' -> SqliteM [Song']
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect Sqlite Song' -> SqliteM [Song'])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect Sqlite Song')
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM [Song']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongT (QGenExpr QValueContext Sqlite QBaseScope)))
Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite Song'
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite Song')
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect Sqlite Song'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> QExpr Sqlite QBaseScope Bool)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\SongT (QGenExpr QValueContext Sqlite QBaseScope)
s -> (SongT (QGenExpr QValueContext Sqlite QBaseScope)
s SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
(QGenExpr QValueContext Sqlite QBaseScope Text)
#identifier) QGenExpr QValueContext Sqlite QBaseScope Text
-> [QGenExpr QValueContext Sqlite QBaseScope Text]
-> QExpr Sqlite QBaseScope Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (UUID -> QGenExpr QValueContext Sqlite QBaseScope Text)
-> [UUID] -> [QGenExpr QValueContext Sqlite QBaseScope Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> QGenExpr QValueContext Sqlite QBaseScope Text
HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (Text -> QGenExpr QValueContext Sqlite QBaseScope Text)
-> (UUID -> Text)
-> UUID
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> Text
UUID.toText) [UUID]
identifiers)
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope)))
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SongSortOrder
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))))
forall {be} {a} {s} {k} {k} {k} {s} {a} {s} {a} {s} {a}
{db :: (* -> *) -> *}.
(Sql92OrderingExpressionSyntax
(Sql92SelectOrderingSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92TableSourceExpressionSyntax
(Sql92FromTableSourceSyntax
(Sql92SelectTableFromSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92GroupingExpressionSyntax
(Sql92SelectTableGroupingSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92ExpressionSelectSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
~ Sql92SelectSyntax (BeamSqlBackendSyntax be),
Sql92ProjectionExpressionSyntax
(Sql92SelectTableProjectionSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92InsertValuesExpressionSyntax
(Sql92InsertValuesSyntax
(Sql92InsertSyntax (BeamSqlBackendSyntax be)))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92FromExpressionSyntax
(Sql92SelectTableFromSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92UpdateFieldNameSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
~ Sql92ExpressionFieldNameSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
ProjectibleWithPredicate
AnyType
be
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
a,
ThreadRewritable (QNested s) a, BeamSqlBackend be, Is k A_Getter,
Is k A_Getter, Is k A_Getter,
LabelOptic "createdAt" k a a (QExpr be s a) (QExpr be s a),
LabelOptic "lastEditedAt" k a a (QExpr be s a) (QExpr be s a),
LabelOptic "displayName" k a a (QExpr be s a) (QExpr be s a),
IsSql92AggregationExpressionSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
Eq
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
HasSqlValueSyntax
(Sql92ExpressionValueSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
SqlNull) =>
SongSortOrder
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
mkOrderBy SongSortOrder
sortOrder
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [Song'])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [Song']
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
-> DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
#songs) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
Env -> [Song'] -> m (Map UUID Song, [UUID])
forall (m :: * -> *).
MonadIO m =>
Env -> [Song'] -> m (Map UUID Song, [UUID])
filledSongs Env
env [Song']
songs
fetchSongArtworks' :: (MonadIO m) => Env -> [UUID] -> m (Map UUID SongArtwork)
fetchSongArtworks' :: forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m (Map UUID SongArtwork)
fetchSongArtworks' Env
env [UUID]
identifiers = do
[SongArtwork']
artworks <- IO [SongArtwork'] -> m [SongArtwork']
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO [SongArtwork'] -> m [SongArtwork'])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO [SongArtwork'])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [SongArtwork']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection -> SqliteM [SongArtwork'] -> IO [SongArtwork']
forall a. Connection -> SqliteM a -> IO a
runBeamSqlite (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM [SongArtwork'] -> IO [SongArtwork'])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM [SongArtwork'])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO [SongArtwork']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SqlSelect Sqlite SongArtwork' -> SqliteM [SongArtwork']
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect Sqlite SongArtwork' -> SqliteM [SongArtwork'])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect Sqlite SongArtwork')
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM [SongArtwork']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(SongArtworkT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongArtworkT (QGenExpr QValueContext Sqlite QBaseScope)))
Q Sqlite
WikiMusicDatabase
QBaseScope
(SongArtworkT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite SongArtwork'
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongArtworkT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite SongArtwork')
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongArtworkT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect Sqlite SongArtwork'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QOrd Sqlite (QNested QBaseScope) Int64)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(SongArtworkT
(QGenExpr QValueContext Sqlite (QNested QBaseScope))))
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QExpr Sqlite (QNested QBaseScope) Int64
-> QOrd Sqlite (QNested QBaseScope) Int64
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
asc_ (QExpr Sqlite (QNested QBaseScope) Int64
-> QOrd Sqlite (QNested QBaseScope) Int64)
-> (SongArtworkT
(QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QExpr Sqlite (QNested QBaseScope) Int64)
-> SongArtworkT
(QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QOrd Sqlite (QNested QBaseScope) Int64
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Optic'
A_Lens
NoIx
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QExpr Sqlite (QNested QBaseScope) Int64)
-> QExpr Sqlite (QNested QBaseScope) Int64
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QExpr Sqlite (QNested QBaseScope) Int64)
#orderValue))
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [SongArtwork'])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [SongArtwork']
forall a b. (a -> b) -> a -> b
$ do
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
songs <-
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QExpr Sqlite (QNested QBaseScope) Bool)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
s -> (SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
s SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
#identifier) QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
-> [QGenExpr QValueContext Sqlite (QNested QBaseScope) Text]
-> QExpr Sqlite (QNested QBaseScope) Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (UUID -> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> [UUID]
-> [QGenExpr QValueContext Sqlite (QNested QBaseScope) Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (Text -> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> (UUID -> Text)
-> UUID
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> Text
UUID.toText) [UUID]
identifiers)
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
-> DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
#songs) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongArtworkT)
-> (SongArtworkT
(QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall be (db :: (* -> *) -> *) (tbl :: (* -> *) -> *)
(rel :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be,
HasTableEquality be (PrimaryKey tbl), Table tbl, Table rel) =>
DatabaseEntity be db (TableEntity rel)
-> (rel (QExpr be s) -> PrimaryKey tbl (QExpr be s))
-> tbl (QExpr be s)
-> Q be db s (rel (QExpr be s))
oneToMany_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongArtworkT))
-> DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongArtworkT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongArtworkT))
#songArtworks) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase) (SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Optic'
A_Lens
NoIx
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongArtworkT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
#songIdentifier) SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
songs
Map UUID SongArtwork -> m (Map UUID SongArtwork)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongArtwork -> m (Map UUID SongArtwork))
-> ([SongArtwork'] -> Map UUID SongArtwork)
-> [SongArtwork']
-> m (Map UUID SongArtwork)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(UUID, SongArtwork)] -> Map UUID SongArtwork
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(UUID, SongArtwork)] -> Map UUID SongArtwork)
-> ([SongArtwork'] -> [(UUID, SongArtwork)])
-> [SongArtwork']
-> Map UUID SongArtwork
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongArtwork' -> (UUID, SongArtwork))
-> [SongArtwork'] -> [(UUID, SongArtwork)]
forall a b. (a -> b) -> [a] -> [b]
map SongArtwork' -> (UUID, SongArtwork)
toSongArtwork ([SongArtwork'] -> m (Map UUID SongArtwork))
-> [SongArtwork'] -> m (Map UUID SongArtwork)
forall a b. (a -> b) -> a -> b
$ [SongArtwork']
artworks
fetchSongComments' :: (MonadIO m) => Env -> [UUID] -> m (Map UUID SongComment)
Env
env [UUID]
identifiers = do
[SongComment']
comments <- IO [SongComment'] -> m [SongComment']
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [SongComment'] -> m [SongComment'])
-> IO [SongComment'] -> m [SongComment']
forall a b. (a -> b) -> a -> b
$ Connection -> SqliteM [SongComment'] -> IO [SongComment']
forall a. Connection -> SqliteM a -> IO a
runBeamSqlite (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn) (SqliteM [SongComment'] -> IO [SongComment'])
-> SqliteM [SongComment'] -> IO [SongComment']
forall a b. (a -> b) -> a -> b
$ SqlSelect Sqlite SongComment' -> SqliteM [SongComment']
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList (SqlSelect Sqlite SongComment' -> SqliteM [SongComment'])
-> SqlSelect Sqlite SongComment' -> SqliteM [SongComment']
forall a b. (a -> b) -> a -> b
$ Q Sqlite
WikiMusicDatabase
QBaseScope
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope)))
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope)))
forall a b. (a -> b) -> a -> b
$ do
SongT (QGenExpr QValueContext Sqlite QBaseScope)
songs <-
(SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> QExpr Sqlite QBaseScope Bool)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\SongT (QGenExpr QValueContext Sqlite QBaseScope)
s -> (SongT (QGenExpr QValueContext Sqlite QBaseScope)
s SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
(QGenExpr QValueContext Sqlite QBaseScope Text)
#identifier) QGenExpr QValueContext Sqlite QBaseScope Text
-> [QGenExpr QValueContext Sqlite QBaseScope Text]
-> QExpr Sqlite QBaseScope Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (UUID -> QGenExpr QValueContext Sqlite QBaseScope Text)
-> [UUID] -> [QGenExpr QValueContext Sqlite QBaseScope Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> QGenExpr QValueContext Sqlite QBaseScope Text
HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (Text -> QGenExpr QValueContext Sqlite QBaseScope Text)
-> (UUID -> Text)
-> UUID
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> Text
UUID.toText) [UUID]
identifiers)
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
-> DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
#songs) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongCommentT)
-> (SongCommentT (QGenExpr QValueContext Sqlite QBaseScope)
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope))
forall be (db :: (* -> *) -> *) (tbl :: (* -> *) -> *)
(rel :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be,
HasTableEquality be (PrimaryKey tbl), Table tbl, Table rel) =>
DatabaseEntity be db (TableEntity rel)
-> (rel (QExpr be s) -> PrimaryKey tbl (QExpr be s))
-> tbl (QExpr be s)
-> Q be db s (rel (QExpr be s))
oneToMany_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongCommentT))
-> DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongCommentT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongCommentT))
#songComments) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase) (SongCommentT (QGenExpr QValueContext Sqlite QBaseScope)
-> Optic'
A_Lens
NoIx
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongCommentT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
#songIdentifier) SongT (QGenExpr QValueContext Sqlite QBaseScope)
songs
Map UUID SongComment -> m (Map UUID SongComment)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongComment -> m (Map UUID SongComment))
-> ([SongComment'] -> Map UUID SongComment)
-> [SongComment']
-> m (Map UUID SongComment)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(UUID, SongComment)] -> Map UUID SongComment
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(UUID, SongComment)] -> Map UUID SongComment)
-> ([SongComment'] -> [(UUID, SongComment)])
-> [SongComment']
-> Map UUID SongComment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongComment' -> (UUID, SongComment))
-> [SongComment'] -> [(UUID, SongComment)]
forall a b. (a -> b) -> [a] -> [b]
map SongComment' -> (UUID, SongComment)
toSongComment ([SongComment'] -> m (Map UUID SongComment))
-> [SongComment'] -> m (Map UUID SongComment)
forall a b. (a -> b) -> a -> b
$ [SongComment']
comments
fetchSongOpinions' :: (MonadIO m) => Env -> [UUID] -> m (Map UUID SongOpinion)
fetchSongOpinions' :: forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m (Map UUID SongOpinion)
fetchSongOpinions' Env
env [UUID]
identifiers = do
[SongOpinion']
opinions <- IO [SongOpinion'] -> m [SongOpinion']
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [SongOpinion'] -> m [SongOpinion'])
-> IO [SongOpinion'] -> m [SongOpinion']
forall a b. (a -> b) -> a -> b
$ Connection -> SqliteM [SongOpinion'] -> IO [SongOpinion']
forall a. Connection -> SqliteM a -> IO a
runBeamSqlite (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn) (SqliteM [SongOpinion'] -> IO [SongOpinion'])
-> SqliteM [SongOpinion'] -> IO [SongOpinion']
forall a b. (a -> b) -> a -> b
$ SqlSelect Sqlite SongOpinion' -> SqliteM [SongOpinion']
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList (SqlSelect Sqlite SongOpinion' -> SqliteM [SongOpinion'])
-> SqlSelect Sqlite SongOpinion' -> SqliteM [SongOpinion']
forall a b. (a -> b) -> a -> b
$ Q Sqlite
WikiMusicDatabase
QBaseScope
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope)))
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope)))
forall a b. (a -> b) -> a -> b
$ do
SongT (QGenExpr QValueContext Sqlite QBaseScope)
songs <-
(SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> QExpr Sqlite QBaseScope Bool)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\SongT (QGenExpr QValueContext Sqlite QBaseScope)
s -> (SongT (QGenExpr QValueContext Sqlite QBaseScope)
s SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
(QGenExpr QValueContext Sqlite QBaseScope Text)
#identifier) QGenExpr QValueContext Sqlite QBaseScope Text
-> [QGenExpr QValueContext Sqlite QBaseScope Text]
-> QExpr Sqlite QBaseScope Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (UUID -> QGenExpr QValueContext Sqlite QBaseScope Text)
-> [UUID] -> [QGenExpr QValueContext Sqlite QBaseScope Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> QGenExpr QValueContext Sqlite QBaseScope Text
HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (Text -> QGenExpr QValueContext Sqlite QBaseScope Text)
-> (UUID -> Text)
-> UUID
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> Text
UUID.toText) [UUID]
identifiers)
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongT (QGenExpr QValueContext Sqlite QBaseScope))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
-> DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
#songs) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongOpinionT)
-> (SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope)
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope))
forall be (db :: (* -> *) -> *) (tbl :: (* -> *) -> *)
(rel :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be,
HasTableEquality be (PrimaryKey tbl), Table tbl, Table rel) =>
DatabaseEntity be db (TableEntity rel)
-> (rel (QExpr be s) -> PrimaryKey tbl (QExpr be s))
-> tbl (QExpr be s)
-> Q be db s (rel (QExpr be s))
oneToMany_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongOpinionT))
-> DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongOpinionT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongOpinionT))
#songOpinions) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase) (SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope)
-> Optic'
A_Lens
NoIx
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongOpinionT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
#songIdentifier) SongT (QGenExpr QValueContext Sqlite QBaseScope)
songs
Map UUID SongOpinion -> m (Map UUID SongOpinion)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongOpinion -> m (Map UUID SongOpinion))
-> ([SongOpinion'] -> Map UUID SongOpinion)
-> [SongOpinion']
-> m (Map UUID SongOpinion)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(UUID, SongOpinion)] -> Map UUID SongOpinion
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(UUID, SongOpinion)] -> Map UUID SongOpinion)
-> ([SongOpinion'] -> [(UUID, SongOpinion)])
-> [SongOpinion']
-> Map UUID SongOpinion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongOpinion' -> (UUID, SongOpinion))
-> [SongOpinion'] -> [(UUID, SongOpinion)]
forall a b. (a -> b) -> [a] -> [b]
map SongOpinion' -> (UUID, SongOpinion)
toSongOpinion ([SongOpinion'] -> m (Map UUID SongOpinion))
-> [SongOpinion'] -> m (Map UUID SongOpinion)
forall a b. (a -> b) -> a -> b
$ [SongOpinion']
opinions
enrichedSongResponse' :: (MonadIO m) => Env -> Map UUID Song -> EnrichSongParams -> m (Map UUID Song)
enrichedSongResponse' :: forall (m :: * -> *).
MonadIO m =>
Env -> Map UUID Song -> EnrichSongParams -> m (Map UUID Song)
enrichedSongResponse' Env
env Map UUID Song
songMap EnrichSongParams
enrichSongParams = do
let isChildOf' :: s -> s -> Bool
isChildOf' s
p s
x = a -> Maybe a
forall a. a -> Maybe a
Just (s
p s -> Optic' k NoIx s a -> a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic k NoIx s s u v
#comment Optic k NoIx s s u v -> Optic l NoIx u v a a -> Optic' k NoIx s a
forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% Optic l NoIx u v a a
#identifier) Maybe a -> Maybe a -> Bool
forall a. Eq a => a -> a -> Bool
== s
x s -> Optic' k NoIx s (Maybe a) -> Maybe a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic k NoIx s s u v
#comment Optic k NoIx s s u v
-> Optic l NoIx u v (Maybe a) (Maybe a)
-> Optic' k NoIx s (Maybe a)
forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% Optic l NoIx u v (Maybe a) (Maybe a)
#parentIdentifier
songIds :: [UUID]
songIds = Map UUID Song -> [UUID]
forall k a. Map k a -> [k]
keys Map UUID Song
songMap
getComment :: IO (Map UUID SongComment)
getComment =
if EnrichSongParams
enrichSongParams EnrichSongParams
-> Optic' A_Lens NoIx EnrichSongParams Bool -> Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx EnrichSongParams Bool
#includeComments
then forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongQuery (Free SongQuery (Map UUID SongComment)
-> IO (Map UUID SongComment))
-> Free SongQuery (Map UUID SongComment)
-> IO (Map UUID SongComment)
forall a b. (a -> b) -> a -> b
$ Env -> [UUID] -> Free SongQuery (Map UUID SongComment)
forall (f :: * -> *).
(SongQuery :<: f) =>
Env -> [UUID] -> Free f (Map UUID SongComment)
fetchSongComments Env
env [UUID]
songIds
else Map UUID SongComment -> IO (Map UUID SongComment)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongComment -> IO (Map UUID SongComment))
-> Map UUID SongComment -> IO (Map UUID SongComment)
forall a b. (a -> b) -> a -> b
$ [Item (Map UUID SongComment)] -> Map UUID SongComment
forall l. IsList l => [Item l] -> l
fromList []
getArtwork :: IO (Map UUID SongArtwork)
getArtwork =
if EnrichSongParams
enrichSongParams EnrichSongParams
-> Optic' A_Lens NoIx EnrichSongParams Bool -> Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx EnrichSongParams Bool
#includeArtworks
then forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongQuery (Free SongQuery (Map UUID SongArtwork)
-> IO (Map UUID SongArtwork))
-> Free SongQuery (Map UUID SongArtwork)
-> IO (Map UUID SongArtwork)
forall a b. (a -> b) -> a -> b
$ Env -> [UUID] -> Free SongQuery (Map UUID SongArtwork)
forall (f :: * -> *).
(SongQuery :<: f) =>
Env -> [UUID] -> Free f (Map UUID SongArtwork)
fetchSongArtworks Env
env [UUID]
songIds
else Map UUID SongArtwork -> IO (Map UUID SongArtwork)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongArtwork -> IO (Map UUID SongArtwork))
-> Map UUID SongArtwork -> IO (Map UUID SongArtwork)
forall a b. (a -> b) -> a -> b
$ [Item (Map UUID SongArtwork)] -> Map UUID SongArtwork
forall l. IsList l => [Item l] -> l
fromList []
getOpinion :: IO (Map UUID SongOpinion)
getOpinion =
if EnrichSongParams
enrichSongParams EnrichSongParams
-> Optic' A_Lens NoIx EnrichSongParams Bool -> Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx EnrichSongParams Bool
#includeOpinions
then forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongQuery (Free SongQuery (Map UUID SongOpinion)
-> IO (Map UUID SongOpinion))
-> Free SongQuery (Map UUID SongOpinion)
-> IO (Map UUID SongOpinion)
forall a b. (a -> b) -> a -> b
$ Env -> [UUID] -> Free SongQuery (Map UUID SongOpinion)
forall (f :: * -> *).
(SongQuery :<: f) =>
Env -> [UUID] -> Free f (Map UUID SongOpinion)
fetchSongOpinions Env
env [UUID]
songIds
else Map UUID SongOpinion -> IO (Map UUID SongOpinion)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongOpinion -> IO (Map UUID SongOpinion))
-> Map UUID SongOpinion -> IO (Map UUID SongOpinion)
forall a b. (a -> b) -> a -> b
$ [Item (Map UUID SongOpinion)] -> Map UUID SongOpinion
forall l. IsList l => [Item l] -> l
fromList []
getArtist :: IO [(UUID, UUID, Text)]
getArtist =
if EnrichSongParams
enrichSongParams EnrichSongParams
-> Optic' A_Lens NoIx EnrichSongParams Bool -> Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx EnrichSongParams Bool
#includeArtists
then forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongQuery (Free SongQuery [(UUID, UUID, Text)] -> IO [(UUID, UUID, Text)])
-> Free SongQuery [(UUID, UUID, Text)] -> IO [(UUID, UUID, Text)]
forall a b. (a -> b) -> a -> b
$ Env -> [UUID] -> Free SongQuery [(UUID, UUID, Text)]
forall (f :: * -> *).
(SongQuery :<: f) =>
Env -> [UUID] -> Free f [(UUID, UUID, Text)]
fetchSongArtists Env
env [UUID]
songIds
else [(UUID, UUID, Text)] -> IO [(UUID, UUID, Text)]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(UUID, UUID, Text)] -> IO [(UUID, UUID, Text)])
-> [(UUID, UUID, Text)] -> IO [(UUID, UUID, Text)]
forall a b. (a -> b) -> a -> b
$ [Item [(UUID, UUID, Text)]] -> [(UUID, UUID, Text)]
forall l. IsList l => [Item l] -> l
fromList []
getContent :: IO (Map UUID SongContent)
getContent =
if EnrichSongParams
enrichSongParams EnrichSongParams
-> Optic' A_Lens NoIx EnrichSongParams Bool -> Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx EnrichSongParams Bool
#includeContents
then forall (f :: * -> *) a. Exec f => Free f a -> IO a
exec @SongQuery (Free SongQuery (Map UUID SongContent)
-> IO (Map UUID SongContent))
-> Free SongQuery (Map UUID SongContent)
-> IO (Map UUID SongContent)
forall a b. (a -> b) -> a -> b
$ Env -> [UUID] -> Free SongQuery (Map UUID SongContent)
forall (f :: * -> *).
(SongQuery :<: f) =>
Env -> [UUID] -> Free f (Map UUID SongContent)
fetchSongContents Env
env [UUID]
songIds
else Map UUID SongContent -> IO (Map UUID SongContent)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongContent -> IO (Map UUID SongContent))
-> Map UUID SongContent -> IO (Map UUID SongContent)
forall a b. (a -> b) -> a -> b
$ [Item (Map UUID SongContent)] -> Map UUID SongContent
forall l. IsList l => [Item l] -> l
fromList []
Map UUID SongArtwork
artworkMap <- IO (Map UUID SongArtwork) -> m (Map UUID SongArtwork)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Map UUID SongArtwork)
getArtwork
Map UUID SongOpinion
opinionMap <- IO (Map UUID SongOpinion) -> m (Map UUID SongOpinion)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Map UUID SongOpinion)
getOpinion
Map UUID SongComment
commentMap <- IO (Map UUID SongComment) -> m (Map UUID SongComment)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Map UUID SongComment)
getComment
Map UUID SongContent
contentMap <- IO (Map UUID SongContent) -> m (Map UUID SongContent)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Map UUID SongContent)
getContent
[(UUID, UUID, Text)]
artistPerSongList <- IO [(UUID, UUID, Text)] -> m [(UUID, UUID, Text)]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO [(UUID, UUID, Text)]
getArtist
let matchesSongIdentifier :: s -> a -> Bool
matchesSongIdentifier s
song = (b -> b -> Bool
forall a. Eq a => a -> a -> Bool
== s
song s -> Optic' k NoIx s b -> b
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx s b
#identifier) (b -> Bool) -> (a -> b) -> a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Optic' k NoIx a b -> b
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx a b
#songIdentifier)
let enrichedSongs :: Map UUID Song
enrichedSongs =
(Song -> Song) -> Map UUID Song -> Map UUID Song
forall a b k. (a -> b) -> Map k a -> Map k b
Map.map
( \Song
song -> do
let rawCommentMap :: Map UUID SongComment
rawCommentMap = (SongComment -> Bool)
-> Map UUID SongComment -> Map UUID SongComment
forall a k. (a -> Bool) -> Map k a -> Map k a
Map.filter (Song -> SongComment -> Bool
forall {k} {k} {b} {s} {a}.
(Is k A_Getter, Is k A_Getter, Eq b,
LabelOptic "identifier" k s s b b,
LabelOptic "songIdentifier" k a a b b) =>
s -> a -> Bool
matchesSongIdentifier Song
song) Map UUID SongComment
commentMap
allComments :: [SongComment]
allComments = Map UUID SongComment -> [SongComment]
forall k a. Map k a -> [a]
elems Map UUID SongComment
rawCommentMap
commentThreads :: [ThreadRender SongComment]
commentThreads = (Thread SongComment -> ThreadRender SongComment)
-> [Thread SongComment] -> [ThreadRender SongComment]
forall a b. (a -> b) -> [a] -> [b]
map Thread SongComment -> ThreadRender SongComment
forall a. Thread a -> ThreadRender a
renderThread ([Thread SongComment] -> [ThreadRender SongComment])
-> [Thread SongComment] -> [ThreadRender SongComment]
forall a b. (a -> b) -> a -> b
$ [SongComment]
-> (SongComment -> SongComment -> Bool)
-> (SongComment -> Maybe UUID)
-> [Thread SongComment]
forall a b. [a] -> (a -> a -> Bool) -> (a -> Maybe b) -> [Thread a]
mkThreads [SongComment]
allComments SongComment -> SongComment -> Bool
forall {k} {l} {k} {k} {l} {k} {a} {u} {v} {u} {v} {s} {s}.
(JoinKinds k l k, JoinKinds k l k, Is k A_Getter, Is k A_Getter,
Eq a, LabelOptic "identifier" l u v a a,
LabelOptic "parentIdentifier" l u v (Maybe a) (Maybe a),
LabelOptic "comment" k s s u v, LabelOptic "comment" k s s u v) =>
s -> s -> Bool
isChildOf' (SongComment
-> Optic' A_Lens NoIx SongComment (Maybe UUID) -> Maybe UUID
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx SongComment SongComment Comment Comment
#comment Optic A_Lens NoIx SongComment SongComment Comment Comment
-> Optic A_Lens NoIx Comment Comment (Maybe UUID) (Maybe UUID)
-> Optic' A_Lens NoIx SongComment (Maybe UUID)
forall k l m (is :: IxList) (js :: IxList) (ks :: IxList) s t u v a
b.
(JoinKinds k l m, AppendIndices is js ks) =>
Optic k is s t u v -> Optic l js u v a b -> Optic m ks s t a b
% Optic A_Lens NoIx Comment Comment (Maybe UUID) (Maybe UUID)
#parentIdentifier)
relevantArtists :: [(UUID, UUID, Text)]
relevantArtists = ((UUID, UUID, Text) -> Bool)
-> [(UUID, UUID, Text)] -> [(UUID, UUID, Text)]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(UUID
songId, UUID
_, Text
_) -> UUID
songId UUID -> UUID -> Bool
forall a. Eq a => a -> a -> Bool
== Song
song Song -> Optic' A_Lens NoIx Song UUID -> UUID
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Song UUID
#identifier) [(UUID, UUID, Text)]
artistPerSongList
Song
song
{ comments = commentThreads,
contents = Map.filter (matchesSongIdentifier song) contentMap,
artworks = Map.filter (matchesSongIdentifier song) artworkMap,
opinions = Map.filter (matchesSongIdentifier song) opinionMap,
artists = Map.fromList $ map (\(UUID
_, UUID
artistId, Text
artistName) -> (UUID
artistId, Text
artistName)) relevantArtists
}
)
Map UUID Song
songMap
Map UUID Song -> m (Map UUID Song)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Map UUID Song
enrichedSongs
fetchSongArtists' :: (MonadIO m) => Env -> [UUID] -> m [(UUID, UUID, Text)]
fetchSongArtists' :: forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m [(UUID, UUID, Text)]
fetchSongArtists' Env
env [UUID]
identifiers = do
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
songArtists <-
IO
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> m [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> m [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Connection
-> SqliteM
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> IO
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall a. Connection -> SqliteM a -> IO a
runBeamSqlite (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> IO
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SqlSelect
Sqlite
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
-> SqliteM
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect
Sqlite
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
-> SqliteM
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))))
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QOrd Sqlite (QNested QBaseScope) UTCTime)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))))
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QGenExpr QValueContext Sqlite (QNested QBaseScope) UTCTime
-> QOrd Sqlite (QNested QBaseScope) UTCTime
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
asc_ (QGenExpr QValueContext Sqlite (QNested QBaseScope) UTCTime
-> QOrd Sqlite (QNested QBaseScope) UTCTime)
-> (SongArtistT
(QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) UTCTime)
-> SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QOrd Sqlite (QNested QBaseScope) UTCTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Optic'
A_Lens
NoIx
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) UTCTime)
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) UTCTime
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) UTCTime)
#createdAt))
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall a b. (a -> b) -> a -> b
$ (SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QExpr Sqlite (QNested QBaseScope) Bool)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
s -> (SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
s SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Optic'
A_Lens
NoIx
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
#songIdentifier) PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> [PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))]
-> QExpr Sqlite (QNested QBaseScope) Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (UUID
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> [UUID]
-> [PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))]
forall a b. (a -> b) -> [a] -> [b]
map (PrimaryKey SongT Identity
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
HaskellLiteralForQExpr
(PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (PrimaryKey SongT Identity
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> (UUID -> PrimaryKey SongT Identity)
-> UUID
-> PrimaryKey
SongT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> PrimaryKey SongT Identity
Columnar Identity Text -> PrimaryKey SongT Identity
forall (f :: * -> *). Columnar f Text -> PrimaryKey SongT f
SongId (Text -> PrimaryKey SongT Identity)
-> (UUID -> Text) -> UUID -> PrimaryKey SongT Identity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> Text
UUID.toText) [UUID]
identifiers)
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongArtistT)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(SongArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongArtistT))
-> DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongArtistT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongArtistT))
#songArtists) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
artists <-
IO
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> m [QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> m [QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> IO ())
-> Connection
-> SqliteM
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> IO
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall a. (String -> IO ()) -> Connection -> SqliteM a -> IO a
runBeamSqliteDebug String -> IO ()
forall (m :: * -> *). MonadIO m => String -> m ()
putStrLn (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> IO
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> IO
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SqlSelect
Sqlite
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
-> SqliteM
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect
Sqlite
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
-> SqliteM
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect
Sqlite
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqliteM
[QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))))
-> (Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> SqlSelect
Sqlite
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QOrd Sqlite (QNested QBaseScope) Text)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))))
forall s a ordering be (db :: (* -> *) -> *).
(Projectible be a, SqlOrderable be ordering,
ThreadRewritable (QNested s) a) =>
(a -> ordering)
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
orderBy_ (QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
-> QOrd Sqlite (QNested QBaseScope) Text
forall be s a. BeamSqlBackend be => QExpr be s a -> QOrd be s a
asc_ (QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
-> QOrd Sqlite (QNested QBaseScope) Text)
-> (ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QOrd Sqlite (QNested QBaseScope) Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Optic'
A_Lens
NoIx
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
#displayName))
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))])
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> m [QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
forall a b. (a -> b) -> a -> b
$ (ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> QExpr Sqlite (QNested QBaseScope) Bool)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
s -> (ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
s ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))
-> Optic'
A_Lens
NoIx
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
#identifier) QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
-> [QGenExpr QValueContext Sqlite (QNested QBaseScope) Text]
-> QExpr Sqlite (QNested QBaseScope) Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> [QGenExpr QValueContext Sqlite (QNested QBaseScope) Text]
forall a b. (a -> b) -> [a] -> [b]
map (HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
-> (QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text))
-> QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> QGenExpr QValueContext Sqlite (QNested QBaseScope) Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrimaryKey ArtistT Identity -> Columnar Identity Text
PrimaryKey ArtistT Identity
-> HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
forall (f :: * -> *). PrimaryKey ArtistT f -> Columnar f Text
fromArtistPk (PrimaryKey ArtistT Identity
-> HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text))
-> (QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> PrimaryKey ArtistT Identity)
-> QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite (QNested QBaseScope) Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey ArtistT Identity)
-> PrimaryKey ArtistT Identity
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey ArtistT Identity)
#artistIdentifier)) [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
songArtists)
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity ArtistT)
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(ArtistT (QGenExpr QValueContext Sqlite (QNested QBaseScope)))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity ArtistT))
-> DatabaseEntity Sqlite WikiMusicDatabase (TableEntity ArtistT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity ArtistT))
#artists) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
let artistMap :: Map (Columnar Identity Text) Text
artistMap = [(Columnar Identity Text, Text)]
-> Map (Columnar Identity Text) Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(Columnar Identity Text, Text)]
-> Map (Columnar Identity Text) Text)
-> [(Columnar Identity Text, Text)]
-> Map (Columnar Identity Text) Text
forall a b. (a -> b) -> a -> b
$ (QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> (Columnar Identity Text, Text))
-> [QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> [(Columnar Identity Text, Text)]
forall a b. (a -> b) -> [a] -> [b]
map (\QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
a -> (QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
a QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> Optic'
A_Lens
NoIx
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(Columnar Identity Text)
-> Columnar Identity Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(Columnar Identity Text)
#identifier, QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
a QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> Optic'
A_Lens
NoIx
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
Text
-> Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
Text
#displayName)) [QExprToIdentity
(ArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
artists
[(UUID, UUID, Text)] -> m [(UUID, UUID, Text)]
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
([(UUID, UUID, Text)] -> m [(UUID, UUID, Text)])
-> [(UUID, UUID, Text)] -> m [(UUID, UUID, Text)]
forall a b. (a -> b) -> a -> b
$ (QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> (UUID, UUID, Text))
-> [QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
-> [(UUID, UUID, Text)]
forall a b. (a -> b) -> [a] -> [b]
map
( \QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
sa ->
( Text -> UUID
textToUUID (Text -> UUID) -> Text -> UUID
forall a b. (a -> b) -> a -> b
$ PrimaryKey SongT Identity -> Columnar Identity Text
forall (f :: * -> *). PrimaryKey SongT f -> Columnar f Text
fromSongPk (PrimaryKey SongT Identity -> Columnar Identity Text)
-> PrimaryKey SongT Identity -> Columnar Identity Text
forall a b. (a -> b) -> a -> b
$ QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
sa QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey SongT Identity)
-> PrimaryKey SongT Identity
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey SongT Identity)
#songIdentifier,
Text -> UUID
textToUUID (Text -> UUID) -> Text -> UUID
forall a b. (a -> b) -> a -> b
$ PrimaryKey ArtistT Identity -> Columnar Identity Text
forall (f :: * -> *). PrimaryKey ArtistT f -> Columnar f Text
fromArtistPk (PrimaryKey ArtistT Identity -> Columnar Identity Text)
-> PrimaryKey ArtistT Identity -> Columnar Identity Text
forall a b. (a -> b) -> a -> b
$ QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
sa QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey ArtistT Identity)
-> PrimaryKey ArtistT Identity
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey ArtistT Identity)
#artistIdentifier,
Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Map (Columnar Identity Text) Text
artistMap Map (Columnar Identity Text) Text
-> Columnar Identity Text -> Maybe Text
forall k a. Ord k => Map k a -> k -> Maybe a
Map.!? PrimaryKey ArtistT Identity -> Columnar Identity Text
forall (f :: * -> *). PrimaryKey ArtistT f -> Columnar f Text
fromArtistPk (QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
sa QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))
-> Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey ArtistT Identity)
-> PrimaryKey ArtistT Identity
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope)))
(PrimaryKey ArtistT Identity)
#artistIdentifier)
)
)
[QExprToIdentity
(SongArtistT (QGenExpr QValueContext Sqlite QBaseScope))]
songArtists
searchSongs' :: (MonadIO m) => Env -> SearchInput -> SongSortOrder -> Limit -> Offset -> m (Map UUID Song, [UUID])
searchSongs' :: forall (m :: * -> *).
MonadIO m =>
Env
-> SearchInput
-> SongSortOrder
-> Limit
-> Offset
-> m (Map UUID Song, [UUID])
searchSongs' Env
env SearchInput
searchInput SongSortOrder
sortOrder (Limit Int
limit) (Offset Int
offset) = do
[Song']
songs <-
IO [Song'] -> m [Song']
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO [Song'] -> m [Song'])
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> IO [Song'])
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> m [Song']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> IO ()) -> Connection -> SqliteM [Song'] -> IO [Song']
forall a. (String -> IO ()) -> Connection -> SqliteM a -> IO a
runBeamSqliteDebug String -> IO ()
forall (m :: * -> *). MonadIO m => String -> m ()
putStrLn (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM [Song'] -> IO [Song'])
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqliteM [Song'])
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> IO [Song']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SqlSelect Sqlite Song' -> SqliteM [Song']
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect Sqlite Song' -> SqliteM [Song'])
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqlSelect Sqlite Song')
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqliteM [Song']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> SqlSelect
Sqlite
(QExprToIdentity
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> SqlSelect Sqlite Song'
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> SqlSelect Sqlite Song')
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> SqlSelect Sqlite Song'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> QExpr Sqlite QBaseScope Bool)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
s -> (WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
s WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> Optic'
A_Lens
NoIx
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
(QGenExpr QValueContext Sqlite QBaseScope Text)
#displayName) QGenExpr QValueContext Sqlite QBaseScope Text
-> QGenExpr QValueContext Sqlite QBaseScope Text
-> QExpr Sqlite QBaseScope Bool
forall be text ctxt s.
(BeamSqlBackendIsString be text, BeamSqlBackend be) =>
QGenExpr ctxt be s text
-> QGenExpr ctxt be s text -> QGenExpr ctxt be s Bool
`like_` HaskellLiteralForQExpr
(QGenExpr QValueContext Sqlite QBaseScope Text)
-> QGenExpr QValueContext Sqlite QBaseScope Text
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (Text
"%" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> SearchInput
searchInput SearchInput -> Optic' An_Iso NoIx SearchInput Text -> Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' An_Iso NoIx SearchInput Text
#value Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"%"))
(Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
forall s a be (db :: (* -> *) -> *).
(Projectible be a, ThreadRewritable (QNested s) a) =>
Integer
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
limit_ (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
limit)
(Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))))
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(WithRewrittenThread
(QNested QBaseScope)
QBaseScope
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
forall s a be (db :: (* -> *) -> *).
(Projectible be a, ThreadRewritable (QNested s) a) =>
Integer
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
offset_ (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
offset)
(Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope))))))
-> (Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested QBaseScope)
(WithRewrittenThread
(QNested (QNested QBaseScope))
(QNested QBaseScope)
(SongT
(QGenExpr QValueContext Sqlite (QNested (QNested QBaseScope)))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SongSortOrder
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested QBaseScope))
(WithRewrittenThread
(QNested (QNested (QNested QBaseScope)))
(QNested (QNested QBaseScope))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope))))))
forall {be} {a} {s} {k} {k} {k} {s} {a} {s} {a} {s} {a}
{db :: (* -> *) -> *}.
(Sql92OrderingExpressionSyntax
(Sql92SelectOrderingSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92TableSourceExpressionSyntax
(Sql92FromTableSourceSyntax
(Sql92SelectTableFromSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be)))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92GroupingExpressionSyntax
(Sql92SelectTableGroupingSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92ExpressionSelectSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)))
~ Sql92SelectSyntax (BeamSqlBackendSyntax be),
Sql92ProjectionExpressionSyntax
(Sql92SelectTableProjectionSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92InsertValuesExpressionSyntax
(Sql92InsertValuesSyntax
(Sql92InsertSyntax (BeamSqlBackendSyntax be)))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92FromExpressionSyntax
(Sql92SelectTableFromSyntax
(Sql92SelectSelectTableSyntax
(Sql92SelectSyntax (BeamSqlBackendSyntax be))))
~ Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be)),
Sql92UpdateFieldNameSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))
~ Sql92ExpressionFieldNameSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
ProjectibleWithPredicate
AnyType
be
(WithExprContext (BeamSqlBackendExpressionSyntax' be))
a,
ThreadRewritable (QNested s) a, BeamSqlBackend be, Is k A_Getter,
Is k A_Getter, Is k A_Getter,
LabelOptic "createdAt" k a a (QExpr be s a) (QExpr be s a),
LabelOptic "lastEditedAt" k a a (QExpr be s a) (QExpr be s a),
LabelOptic "displayName" k a a (QExpr be s a) (QExpr be s a),
IsSql92AggregationExpressionSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
Eq
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))),
HasSqlValueSyntax
(Sql92ExpressionValueSyntax
(Sql92UpdateExpressionSyntax
(Sql92UpdateSyntax (BeamSqlBackendSyntax be))))
SqlNull) =>
SongSortOrder
-> Q be db (QNested s) a
-> Q be db s (WithRewrittenThread (QNested s) s a)
mkOrderBy SongSortOrder
sortOrder
(Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> m [Song'])
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
-> m [Song']
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
-> Q Sqlite
WikiMusicDatabase
(QNested (QNested (QNested QBaseScope)))
(SongT (QExpr Sqlite (QNested (QNested (QNested QBaseScope)))))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
-> DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongT))
#songs) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
Env -> [Song'] -> m (Map UUID Song, [UUID])
forall (m :: * -> *).
MonadIO m =>
Env -> [Song'] -> m (Map UUID Song, [UUID])
filledSongs Env
env [Song']
songs
fetchSongContents' :: (MonadIO m) => Env -> [UUID] -> m (Map UUID SongContent)
fetchSongContents' :: forall (m :: * -> *).
MonadIO m =>
Env -> [UUID] -> m (Map UUID SongContent)
fetchSongContents' Env
env [UUID]
identifiers = do
[SongContents']
contents <-
IO [SongContents'] -> m [SongContents']
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO [SongContents'] -> m [SongContents'])
-> (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> IO [SongContents'])
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> m [SongContents']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> IO ())
-> Connection -> SqliteM [SongContents'] -> IO [SongContents']
forall a. (String -> IO ()) -> Connection -> SqliteM a -> IO a
runBeamSqliteDebug String -> IO ()
forall (m :: * -> *). MonadIO m => String -> m ()
putStrLn (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM [SongContents'] -> IO [SongContents'])
-> (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqliteM [SongContents'])
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> IO [SongContents']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SqlSelect Sqlite SongContents' -> SqliteM [SongContents']
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect Sqlite SongContents' -> SqliteM [SongContents'])
-> (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite SongContents')
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqliteM [SongContents']
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope)))
Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite SongContents'
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite SongContents')
-> (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite SongContents'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongContentsT (QGenExpr QValueContext Sqlite QBaseScope)
-> QExpr Sqlite QBaseScope Bool)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\SongContentsT (QGenExpr QValueContext Sqlite QBaseScope)
s -> (SongContentsT (QGenExpr QValueContext Sqlite QBaseScope)
s SongContentsT (QGenExpr QValueContext Sqlite QBaseScope)
-> Optic'
A_Lens
NoIx
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
#songIdentifier) PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> [PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)]
-> QExpr Sqlite QBaseScope Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (UUID
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> [UUID]
-> [PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)]
forall a b. (a -> b) -> [a] -> [b]
map (PrimaryKey SongT Identity
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
HaskellLiteralForQExpr
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (PrimaryKey SongT Identity
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> (UUID -> PrimaryKey SongT Identity)
-> UUID
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> PrimaryKey SongT Identity
Columnar Identity Text -> PrimaryKey SongT Identity
forall (f :: * -> *). Columnar f Text -> PrimaryKey SongT f
SongId (Text -> PrimaryKey SongT Identity)
-> (UUID -> Text) -> UUID -> PrimaryKey SongT Identity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UUID -> Text
UUID.toText) [UUID]
identifiers)
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> m [SongContents'])
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
-> m [SongContents']
forall a b. (a -> b) -> a -> b
$ DatabaseEntity Sqlite WikiMusicDatabase (TableEntity SongContentsT)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongContentsT (QGenExpr QValueContext Sqlite QBaseScope))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongContentsT))
-> DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongContentsT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongContentsT))
#songContents) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
Map UUID SongContent -> m (Map UUID SongContent)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map UUID SongContent -> m (Map UUID SongContent))
-> Map UUID SongContent -> m (Map UUID SongContent)
forall a b. (a -> b) -> a -> b
$ [(UUID, SongContent)] -> Map UUID SongContent
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(UUID, SongContent)] -> Map UUID SongContent)
-> [(UUID, SongContent)] -> Map UUID SongContent
forall a b. (a -> b) -> a -> b
$ (SongContents' -> (UUID, SongContent))
-> [SongContents'] -> [(UUID, SongContent)]
forall a b. (a -> b) -> [a] -> [b]
map (\SongContents'
x -> (Text -> UUID
textToUUID (Text -> UUID) -> Text -> UUID
forall a b. (a -> b) -> a -> b
$ SongContents'
x SongContents' -> Optic' A_Lens NoIx SongContents' Text -> Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx SongContents' Text
#identifier, SongContents' -> SongContent
mkSongContentsM SongContents'
x)) [SongContents']
contents
filledSongs :: (MonadIO m) => Env -> [Song'] -> m (Map UUID Song, [UUID])
filledSongs :: forall (m :: * -> *).
MonadIO m =>
Env -> [Song'] -> m (Map UUID Song, [UUID])
filledSongs Env
env [Song']
songs = do
[SongExternalSourcesT Identity]
externalSources <-
IO [SongExternalSourcesT Identity]
-> m [SongExternalSourcesT Identity]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
(IO [SongExternalSourcesT Identity]
-> m [SongExternalSourcesT Identity])
-> IO [SongExternalSourcesT Identity]
-> m [SongExternalSourcesT Identity]
forall a b. (a -> b) -> a -> b
$ (String -> IO ())
-> Connection
-> SqliteM [SongExternalSourcesT Identity]
-> IO [SongExternalSourcesT Identity]
forall a. (String -> IO ()) -> Connection -> SqliteM a -> IO a
runBeamSqliteDebug String -> IO ()
forall (m :: * -> *). MonadIO m => String -> m ()
putStrLn (Env
env Env -> Optic' A_Lens NoIx Env Connection -> Connection
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Env Connection
#conn)
(SqliteM [SongExternalSourcesT Identity]
-> IO [SongExternalSourcesT Identity])
-> SqliteM [SongExternalSourcesT Identity]
-> IO [SongExternalSourcesT Identity]
forall a b. (a -> b) -> a -> b
$ SqlSelect Sqlite (SongExternalSourcesT Identity)
-> SqliteM [SongExternalSourcesT Identity]
forall be (m :: * -> *) a.
(MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>
SqlSelect be a -> m [a]
runSelectReturningList
(SqlSelect Sqlite (SongExternalSourcesT Identity)
-> SqliteM [SongExternalSourcesT Identity])
-> (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite (SongExternalSourcesT Identity))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqliteM [SongExternalSourcesT Identity]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect
Sqlite
(QExprToIdentity
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope)))
Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite (SongExternalSourcesT Identity)
forall be (db :: (* -> *) -> *) res.
(BeamSqlBackend be, HasQBuilder be, Projectible be res) =>
Q be db QBaseScope res -> SqlSelect be (QExprToIdentity res)
select
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite (SongExternalSourcesT Identity))
-> (Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope)))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqlSelect Sqlite (SongExternalSourcesT Identity)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope)
-> QExpr Sqlite QBaseScope Bool)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
forall r be (db :: (* -> *) -> *) s.
BeamSqlBackend be =>
(r -> QExpr be s Bool) -> Q be db s r -> Q be db s r
filter_ (\SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope)
s -> (SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope)
s SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope)
-> Optic'
A_Lens
NoIx
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
#songIdentifier) PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
-> [PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)]
-> QExpr Sqlite QBaseScope Bool
forall (expr :: * -> *) a. SqlIn expr a => a -> [a] -> expr Bool
`in_` (Song'
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> [Song']
-> [PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)]
forall a b. (a -> b) -> [a] -> [b]
map (PrimaryKey SongT Identity
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
HaskellLiteralForQExpr
(PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall a. SqlValable a => HaskellLiteralForQExpr a -> a
val_ (PrimaryKey SongT Identity
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope))
-> (Song' -> PrimaryKey SongT Identity)
-> Song'
-> PrimaryKey SongT (QGenExpr QValueContext Sqlite QBaseScope)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\Song'
x -> Columnar Identity Text -> PrimaryKey SongT Identity
forall (f :: * -> *). Columnar f Text -> PrimaryKey SongT f
SongId (Columnar Identity Text -> PrimaryKey SongT Identity)
-> Columnar Identity Text -> PrimaryKey SongT Identity
forall a b. (a -> b) -> a -> b
$ Song'
x Song'
-> Optic' A_Lens NoIx Song' (Columnar Identity Text)
-> Columnar Identity Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Song' (Columnar Identity Text)
#identifier)) [Song']
songs)
(Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqliteM [SongExternalSourcesT Identity])
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
-> SqliteM [SongExternalSourcesT Identity]
forall a b. (a -> b) -> a -> b
$ DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongExternalSourcesT)
-> Q Sqlite
WikiMusicDatabase
QBaseScope
(SongExternalSourcesT (QGenExpr QValueContext Sqlite QBaseScope))
forall be (db :: (* -> *) -> *) (table :: (* -> *) -> *) s.
(Database be db, BeamSqlBackend be) =>
DatabaseEntity be db (TableEntity table)
-> Q be db s (table (QExpr be s))
all_ ((DatabaseSettings Sqlite WikiMusicDatabase
-> Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongExternalSourcesT))
-> DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongExternalSourcesT)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens
NoIx
(DatabaseSettings Sqlite WikiMusicDatabase)
(DatabaseEntity
Sqlite WikiMusicDatabase (TableEntity SongExternalSourcesT))
#songExternalSources) DatabaseSettings Sqlite WikiMusicDatabase
forall be. DatabaseSettings be WikiMusicDatabase
wikiMusicDatabase)
let filledSongs' :: [(UUID, Song)]
filledSongs' = (Song' -> (UUID, Song)) -> [Song'] -> [(UUID, Song)]
forall a b. (a -> b) -> [a] -> [b]
map ([SongExternalSourcesT Identity] -> Song' -> (UUID, Song)
forall {f :: * -> *} {k1} {k2} {k3} {k4} {k} {s}.
(Columnar f Text ~ Text, Is k1 A_Getter, Is k2 A_Getter,
Is k3 A_Getter, Is k4 A_Getter, Is k A_Getter,
LabelOptic "spotifyUrl" k3 s s (Maybe Text) (Maybe Text),
LabelOptic "youtubeUrl" k2 s s (Maybe Text) (Maybe Text),
LabelOptic "soundcloudUrl" k4 s s (Maybe Text) (Maybe Text),
LabelOptic "wikipediaUrl" k1 s s (Maybe Text) (Maybe Text),
LabelOptic
"songIdentifier"
k
s
s
(PrimaryKey SongT f)
(PrimaryKey SongT f)) =>
[s] -> Song' -> (UUID, Song)
withExternalSources [SongExternalSourcesT Identity]
externalSources) [Song']
songs
(Map UUID Song, [UUID]) -> m (Map UUID Song, [UUID])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(UUID, Song)] -> Map UUID Song
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(UUID, Song)]
filledSongs', (Song' -> UUID) -> [Song'] -> [UUID]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> UUID
textToUUID (Text -> UUID) -> (Song' -> Text) -> Song' -> UUID
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Song' -> Optic' A_Lens NoIx Song' Text -> Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Song' Text
#identifier)) [Song']
songs)
where
withExternalSources :: [s] -> Song' -> (UUID, Song)
withExternalSources [s]
externalSources Song'
song =
let maybeFoundExternal :: Maybe ExternalSources
maybeFoundExternal =
(NonEmpty s -> ExternalSources)
-> Maybe (NonEmpty s) -> Maybe ExternalSources
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
(s -> ExternalSources
forall {k1} {k2} {k3} {k4} {s}.
(Is k1 A_Getter, Is k2 A_Getter, Is k3 A_Getter, Is k4 A_Getter,
LabelOptic "spotifyUrl" k3 s s (Maybe Text) (Maybe Text),
LabelOptic "youtubeUrl" k2 s s (Maybe Text) (Maybe Text),
LabelOptic "soundcloudUrl" k4 s s (Maybe Text) (Maybe Text),
LabelOptic "wikipediaUrl" k1 s s (Maybe Text) (Maybe Text)) =>
s -> ExternalSources
fromPersistenceExternalSource (s -> ExternalSources)
-> (NonEmpty s -> s) -> NonEmpty s -> ExternalSources
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty s -> s
forall (f :: * -> *) a. IsNonEmpty f a a "head" => f a -> a
head)
([s] -> Maybe (NonEmpty s)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty ([s] -> Maybe (NonEmpty s)) -> [s] -> Maybe (NonEmpty s)
forall a b. (a -> b) -> a -> b
$ (s -> Bool) -> [s] -> [s]
forall a. (a -> Bool) -> [a] -> [a]
filter (\s
x -> PrimaryKey SongT f -> Columnar f Text
forall (f :: * -> *). PrimaryKey SongT f -> Columnar f Text
fromSongPk (s
x s -> Optic' k NoIx s (PrimaryKey SongT f) -> PrimaryKey SongT f
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' k NoIx s (PrimaryKey SongT f)
#songIdentifier) Columnar f Text -> Columnar f Text -> Bool
forall a. Eq a => a -> a -> Bool
== Song'
song Song'
-> Optic' A_Lens NoIx Song' (Columnar f Text) -> Columnar f Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx Song' (Columnar f Text)
#identifier) [s]
externalSources)
in Song' -> ExternalSources -> (UUID, Song)
toSong Song'
song (ExternalSources -> Maybe ExternalSources -> ExternalSources
forall a. a -> Maybe a -> a
fromMaybe ExternalSources
emptyExternalSources Maybe ExternalSources
maybeFoundExternal)