lastExerciseId :: ReaderT SqlBackend Handler ExerciseId
lastExerciseId = getVal <$> rawSql query []
  where
    getVal (Single c:_)  = c
    getVal [] = toSqlKey 0
    query = unlines
          ["SELECT max(id) FROM exercise;"
          ]
lastExerciseId :: ReaderT SqlBackend Handler ExerciseId
lastExerciseId = getVal <$> rawSql query []
  where
    getVal (Single c:_)  = c
    getVal [] = toSqlKey 0
    query = unlines
          ["SELECT max(id) FROM exercise;"
          ]
lastExerciseId = getVal <$> rawSql query []
  where
    getVal (Single c:_)  = c
    getVal [] = toSqlKey 0
    query = unlines
          ["SELECT max(id) FROM exercise;"
          ]