eidolon/Helper.hs

36 lines
765 B
Haskell
Raw Normal View History

2014-08-13 22:52:57 +00:00
module Helper
( getUserIdFromText
2014-08-14 00:25:18 +00:00
, extractKey
-- , getUserNameById
2014-08-13 22:52:57 +00:00
)
where
import Prelude
2014-08-15 11:24:14 +00:00
import Model
import Control.Applicative
import Control.Monad.Trans.Class
2014-08-13 22:52:57 +00:00
import Data.Text
2014-08-15 11:24:14 +00:00
import Data.Maybe
import Database.Persist
2014-08-13 22:52:57 +00:00
import Database.Persist.Types
2014-08-15 11:24:14 +00:00
import System.FilePath
import Yesod.Persist.Core
import Yesod.Core.Types
2014-08-13 22:52:57 +00:00
2014-08-15 11:24:14 +00:00
getUserIdFromText :: Text -> UserId
2014-08-13 22:52:57 +00:00
getUserIdFromText tempUserId =
2014-08-15 12:50:03 +00:00
Key $ PersistInt64 $ fromIntegral $ read $ unpack tempUserId
2014-08-14 00:25:18 +00:00
extractKey :: KeyBackend backend entity -> Text
extractKey = extractKey' . unKey
where
extractKey' (PersistInt64 k) = pack $ show k
extractKey' _ = ""
2014-08-15 11:24:14 +00:00
--getUserNameById :: UserId -> Text
--getUserNameById userId =
2014-08-15 11:24:14 +00:00
-- let
-- user = runDB $ getJust $ userId
2014-08-15 11:24:14 +00:00
-- in
-- userName user