import Data.Text (Text)
import Data.Time (UTCTime)
import GHC.Show(Show(..))
-import Gargantext.Core.Types.Individu (Username)
+import Gargantext.Core.Types.Individu (Username, arbitraryUsername)
import Gargantext.Database.Utils
import Gargantext.Prelude
import Opaleye
------------------------------------------------------------------------
-type UserId = Int
+------------------------------------------------------------------------
+type UserId = Int
data UserLight = UserLight { userLight_id :: Int
, userLight_username :: Text
(Column PGBool) (Column PGBool)
(Column PGTimestamptz)
+type UserReadNull = UserPoly (Column (Nullable PGInt4)) (Column (Nullable PGText))
+ (Column (Nullable PGTimestamptz)) (Column (Nullable PGBool))
+ (Column (Nullable PGText)) (Column (Nullable PGText))
+ (Column (Nullable PGText)) (Column (Nullable PGText))
+ (Column (Nullable PGBool)) (Column (Nullable PGBool))
+ (Column (Nullable PGTimestamptz))
+
+
+
+
type User = UserPoly Int Text (Maybe UTCTime) Bool Text Text Text Text Bool Bool UTCTime
$(makeAdaptorAndInstance "pUser" ''UserPoly)
-- TODO: on conflict, nice message
insertUsers :: [UserWrite] -> Cmd err Int64
-insertUsers us = mkCmd $ \c -> runInsertMany c userTable us
+insertUsers us = mkCmd $ \c -> runInsert_ c insert
+ where
+ insert = Insert userTable us rCount Nothing
+
-gargantuaUser :: UserWrite
-gargantuaUser = User (Nothing) (pgStrictText "password")
- (Nothing) (pgBool True) (pgStrictText "gargantua")
+gargantextUser :: Username -> UserWrite
+gargantextUser u = User (Nothing) (pgStrictText "password")
+ (Nothing) (pgBool True) (pgStrictText u)
(pgStrictText "first_name")
(pgStrictText "last_name")
(pgStrictText "e@mail")
(pgBool True) (pgBool True) (Nothing)
-simpleUser :: UserWrite
-simpleUser = User (Nothing) (pgStrictText "password")
- (Nothing) (pgBool False) (pgStrictText "user1")
- (pgStrictText "first_name")
- (pgStrictText "last_name")
- (pgStrictText "e@mail")
- (pgBool False) (pgBool True) (Nothing)
+insertUsersDemo :: Cmd err Int64
+insertUsersDemo = insertUsers $ map (\u -> gargantextUser u) arbitraryUsername
------------------------------------------------------------------