getDistinctAlgorithmVersionQuery
    :: Key Algorithm -> Maybe Text -> Query CommitId
getDistinctAlgorithmVersionQuery algoId prefix = Query
  { queryName = "distinctAlgorithmVersionQuery"
  , commonTableExpressions = []
  , params =
        [ toPersistValue algoId
        , toPersistValue prefix
        , toPersistValue prefix
        ]
  , queryText = [i|
SELECT DISTINCT algorithmVersion
FROM RunConfig
WHERE algorithmId = ? AND (algorithmVersion LIKE (? || '%') OR ? IS NULL)
|]
  , convert = Simple converter
  , ..
  }
  where
    converter
        :: (MonadIO n, MonadLogger n, MonadThrow n)
        => [PersistValue] -> n CommitId
    converter [v] | Right val <- Sqlite.fromPersistValue v = return val
    converter actualValues = logThrowM $ QueryResultUnparseable actualValues
        [Sqlite.sqlType (Proxy :: Proxy CommitId)]
getDistinctAlgorithmVersionQuery
    :: Key Algorithm -> Maybe Text -> Query CommitId
getDistinctAlgorithmVersionQuery algoId prefix = Query
  { queryName = "distinctAlgorithmVersionQuery"
  , commonTableExpressions = []
  , params =
        [ toPersistValue algoId
        , toPersistValue prefix
        , toPersistValue prefix
        ]
  , queryText = [i|
SELECT DISTINCT algorithmVersion
FROM RunConfig
WHERE algorithmId = ? AND (algorithmVersion LIKE (? || '%') OR ? IS NULL)
|]
  , convert = Simple converter
  , ..
  }
  where
    converter
        :: (MonadIO n, MonadLogger n, MonadThrow n)
        => [PersistValue] -> n CommitId
    converter [v] | Right val <- Sqlite.fromPersistValue v = return val
    converter actualValues = logThrowM $ QueryResultUnparseable actualValues
        [Sqlite.sqlType (Proxy :: Proxy CommitId)]
getDistinctAlgorithmVersionQuery algoId prefix = Query
  { queryName = "distinctAlgorithmVersionQuery"
  , commonTableExpressions = []
  , params =
        [ toPersistValue algoId
        , toPersistValue prefix
        , toPersistValue prefix
        ]
  , queryText = [i|
SELECT DISTINCT algorithmVersion
FROM RunConfig
WHERE algorithmId = ? AND (algorithmVersion LIKE (? || '%') OR ? IS NULL)
|]
  , convert = Simple converter
  , ..
  }
  where
    converter
        :: (MonadIO n, MonadLogger n, MonadThrow n)
        => [PersistValue] -> n CommitId
    converter [v] | Right val <- Sqlite.fromPersistValue v = return val
    converter actualValues = logThrowM $ QueryResultUnparseable actualValues
        [Sqlite.sqlType (Proxy :: Proxy CommitId)]