Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
4c6051cc
Commit
4c6051cc
authored
Dec 03, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
[FIX MERGE] with dev and testing (social lists)
parents
d3547991
20e86c92
Pipeline
#1272
failed with stage
Changes
14
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
95 additions
and
51 deletions
+95
-51
Main.hs
bin/gargantext-import/Main.hs
+0
-8
Main.hs
bin/gargantext-init/Main.hs
+14
-4
build-shell.nix
build-shell.nix
+1
-1
pinned-20.09.nix
pinned-20.09.nix
+11
-0
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+2
-0
Node.hs
src/Gargantext/API/Node.hs
+2
-2
Share.hs
src/Gargantext/API/Node/Share.hs
+33
-13
List.hs
src/Gargantext/Core/Text/List.hs
+5
-5
WithStem.hs
src/Gargantext/Core/Text/List/Group/WithStem.hs
+3
-3
Individu.hs
src/Gargantext/Core/Types/Individu.hs
+5
-4
User.hs
src/Gargantext/Database/Action/User.hs
+1
-1
New.hs
src/Gargantext/Database/Action/User/New.hs
+10
-4
User.hs
src/Gargantext/Database/Query/Table/User.hs
+5
-5
Job.hs
src/Gargantext/Prelude/Job.hs
+3
-1
No files found.
bin/gargantext-import/Main.hs
View file @
4c6051cc
...
@@ -29,7 +29,6 @@ import Gargantext.API.Prelude (GargError)
...
@@ -29,7 +29,6 @@ import Gargantext.API.Prelude (GargError)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Action.Flow
(
FlowCmdM
,
flowCorpusFile
,
flowAnnuaire
,
TermType
(
..
))
import
Gargantext.Database.Action.Flow
(
FlowCmdM
,
flowCorpusFile
,
flowAnnuaire
,
TermType
(
..
))
import
Gargantext.Database.Query.Table.User
(
insertUsersDemo
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
toHyperdataDocument
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
toHyperdataDocument
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
)
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Prelude
(
Cmd
)
...
@@ -42,9 +41,6 @@ main = do
...
@@ -42,9 +41,6 @@ main = do
--{-
--{-
let
createUsers
::
Cmd
GargError
Int64
createUsers
=
insertUsersDemo
let
let
--tt = (Unsupervised EN 6 0 Nothing)
--tt = (Unsupervised EN 6 0 Nothing)
tt
=
(
Multi
EN
)
tt
=
(
Multi
EN
)
...
@@ -70,10 +66,6 @@ main = do
...
@@ -70,10 +66,6 @@ main = do
--}
--}
withDevEnv
iniPath
$
\
env
->
do
withDevEnv
iniPath
$
\
env
->
do
_
<-
if
fun
==
"users"
then
runCmdDev
env
createUsers
else
pure
0
--(cs "false")
_
<-
if
fun
==
"corpus"
_
<-
if
fun
==
"corpus"
then
runCmdDev
env
corpus
then
runCmdDev
env
corpus
else
pure
0
--(cs "false")
else
pure
0
--(cs "false")
...
...
bin/gargantext-init/Main.hs
View file @
4c6051cc
...
@@ -20,10 +20,10 @@ import Data.Either (Either(..))
...
@@ -20,10 +20,10 @@ import Data.Either (Either(..))
import
Gargantext.API.Dev
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Dev
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Prelude
(
GargError
)
import
Gargantext.API.Prelude
(
GargError
)
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
)
,
arbitraryNewUsers
,
NewUser
(
..
),
arbitraryUsername
,
GargPassword
(
..
)
)
import
Gargantext.Database.Action.Flow
(
getOrMkRoot
,
getOrMk_RootWithCorpus
)
import
Gargantext.Database.Action.Flow
(
getOrMkRoot
,
getOrMk_RootWithCorpus
)
import
Gargantext.Database.Query.Table.Node
(
getOrMkList
)
import
Gargantext.Database.Query.Table.Node
(
getOrMkList
)
import
Gargantext.Database.Query.Table.User
(
insert
UsersDemo
)
import
Gargantext.Database.Query.Table.User
(
insert
NewUsers
,
)
import
Gargantext.Database.Admin.Config
(
userMaster
,
corpusMasterName
)
import
Gargantext.Database.Admin.Config
(
userMaster
,
corpusMasterName
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Trigger.Init
(
initFirstTriggers
,
initLastTriggers
)
import
Gargantext.Database.Admin.Trigger.Init
(
initFirstTriggers
,
initLastTriggers
)
...
@@ -31,6 +31,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataCorpus)
...
@@ -31,6 +31,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataCorpus)
import
Gargantext.Database.Prelude
(
Cmd
,
)
import
Gargantext.Database.Prelude
(
Cmd
,
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
System.Environment
(
getArgs
)
import
System.Environment
(
getArgs
)
import
Prelude
(
getLine
)
-- TODO put this in gargantext.ini
-- TODO put this in gargantext.ini
secret
::
Text
secret
::
Text
...
@@ -40,12 +41,21 @@ main :: IO ()
...
@@ -40,12 +41,21 @@ main :: IO ()
main
=
do
main
=
do
[
iniPath
]
<-
getArgs
[
iniPath
]
<-
getArgs
putStrLn
"Enter master user (gargantua) _password_ :"
password
<-
getLine
putStrLn
"Enter master user (gargantua) _email_ :"
email
<-
getLine
let
createUsers
::
Cmd
GargError
Int64
let
createUsers
::
Cmd
GargError
Int64
createUsers
=
insertUsersDemo
createUsers
=
insertNewUsers
(
NewUser
"gargantua"
(
cs
email
)
(
GargPassword
$
cs
password
)
:
arbitraryNewUsers
)
let
let
mkRoots
::
Cmd
GargError
[(
UserId
,
RootId
)]
mkRoots
::
Cmd
GargError
[(
UserId
,
RootId
)]
mkRoots
=
mapM
getOrMkRoot
$
map
UserName
[
"gargantua"
,
"user1"
,
"user2"
,
"user3"
]
mkRoots
=
mapM
getOrMkRoot
$
map
UserName
(
"gargantua"
:
arbitraryUsername
)
-- TODO create all users roots
-- TODO create all users roots
let
let
...
...
build-shell.nix
View file @
4c6051cc
{
ghc
{
ghc
,
pkgs
?
import
./pinned.nix
{}
,
pkgs
?
import
./pinned
-20.09
.nix
{}
}:
}:
let
let
buildInputs
=
with
pkgs
;
[
buildInputs
=
with
pkgs
;
[
...
...
pinned-20.09.nix
0 → 100644
View file @
4c6051cc
# this version of nixpkgs contains liblapack at ?
# this version of nixpkgs contains gsl at ?
import
(
builtins
.
fetchGit
{
# Descriptive name to make the store path easier to identify
name
=
"nixos-20.09"
;
url
=
"https://github.com/nixos/nixpkgs/"
;
# Last commit hash for nixos-unstable
# `git ls-remote https://github.com/nixos/nixpkgs-channels nixos-20.09`
ref
=
"refs/heads/nixos-20.09"
;
rev
=
"19db3e5ea2777daa874563b5986288151f502e27"
;
})
src/Gargantext/API/Ngrams.hs
View file @
4c6051cc
...
@@ -419,6 +419,7 @@ tableNgramsPostChartsAsync utn logStatus = do
...
@@ -419,6 +419,7 @@ tableNgramsPostChartsAsync utn logStatus = do
-- printDebug "[tableNgramsPut] Terms, updating Metrics (Histo), cId" cId
-- printDebug "[tableNgramsPut] Terms, updating Metrics (Histo), cId" cId
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
6
logStatus
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
6
logStatus
logRef
logRef
{-
_ <- Metrics.updateChart cId (Just listId) tabType Nothing
_ <- Metrics.updateChart cId (Just listId) tabType Nothing
logRefSuccess
logRefSuccess
_ <- Metrics.updatePie cId (Just listId) tabType Nothing
_ <- Metrics.updatePie cId (Just listId) tabType Nothing
...
@@ -430,6 +431,7 @@ tableNgramsPostChartsAsync utn logStatus = do
...
@@ -430,6 +431,7 @@ tableNgramsPostChartsAsync utn logStatus = do
_ <- Metrics.updateTree cId (Just listId) tabType CandidateTerm
_ <- Metrics.updateTree cId (Just listId) tabType CandidateTerm
logRefSuccess
logRefSuccess
_ <- Metrics.updateTree cId (Just listId) tabType MapTerm
_ <- Metrics.updateTree cId (Just listId) tabType MapTerm
-}
logRefSuccess
logRefSuccess
getRef
getRef
...
...
src/Gargantext/API/Node.hs
View file @
4c6051cc
...
@@ -210,10 +210,10 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
...
@@ -210,10 +210,10 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
-- TODO gather it
-- TODO gather it
:<|>
tableApi
id'
:<|>
tableApi
id'
:<|>
apiNgramsTableCorpus
id'
:<|>
apiNgramsTableCorpus
id'
:<|>
catApi
id'
:<|>
catApi
id'
:<|>
Search
.
api
id'
:<|>
Search
.
api
id'
:<|>
Share
.
api
id'
:<|>
Share
.
api
(
RootId
$
NodeId
uId
)
id'
-- Pairing Tools
-- Pairing Tools
:<|>
pairWith
id'
:<|>
pairWith
id'
:<|>
pairs
id'
:<|>
pairs
id'
...
...
src/Gargantext/API/Node/Share.hs
View file @
4c6051cc
...
@@ -19,20 +19,21 @@ import Data.Aeson
...
@@ -19,20 +19,21 @@ import Data.Aeson
import
Data.Swagger
import
Data.Swagger
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
import
Gargantext.API.Prelude
import
Gargantext.API.Prelude
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
),
arbitraryUsername
)
import
Gargantext.Database.Action.User
import
Gargantext.Database.Action.User.New
import
Gargantext.Database.Action.Share
(
ShareNodeWith
(
..
))
import
Gargantext.Database.Action.Share
(
ShareNodeWith
(
..
))
import
Gargantext.Database.Action.Share
as
DB
(
shareNodeWith
,
unPublish
)
import
Gargantext.Database.Action.Share
as
DB
(
shareNodeWith
,
unPublish
)
import
Gargantext.Database.Action.User
import
Gargantext.Database.Action.User.New
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
import
Gargantext.Database.Prelude
import
Gargantext.Database.Query.Tree
(
findNodesId
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
import
qualified
Data.List
as
List
------------------------------------------------------------------------
------------------------------------------------------------------------
data
ShareNodeParams
=
ShareTeamParams
{
username
::
Text
}
data
ShareNodeParams
=
ShareTeamParams
{
username
::
Text
}
...
@@ -51,23 +52,42 @@ instance Arbitrary ShareNodeParams where
...
@@ -51,23 +52,42 @@ instance Arbitrary ShareNodeParams where
]
]
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO permission
-- TODO permission
-- TODO refactor userId which is used twice
-- TODO change return type for better warning/info/success/error handling on the front
api
::
HasNodeError
err
api
::
HasNodeError
err
=>
NodeId
=>
User
->
NodeId
->
ShareNodeParams
->
ShareNodeParams
->
CmdR
err
Int
->
CmdR
err
Int
api
nId
(
ShareTeamParams
user'
)
=
do
api
userInviting
nId
(
ShareTeamParams
user'
)
=
do
user
<-
case
guessUserName
user'
of
user
<-
case
guessUserName
user'
of
Nothing
->
pure
user'
Nothing
->
pure
user'
Just
(
u
,
_
)
->
do
Just
(
u
,
_
)
->
do
isRegistered
<-
getUserId'
(
UserName
u
)
isRegistered
<-
getUserId'
(
UserName
u
)
case
isRegistered
of
case
isRegistered
of
Just
_
->
pure
u
Just
_
->
do
printDebug
"[G.A.N.Share.api]"
(
"Team shared with "
<>
u
)
pure
u
Nothing
->
do
Nothing
->
do
_
<-
newUsers
[
u
]
username'
<-
getUsername
userInviting
_
<-
case
List
.
elem
username'
arbitraryUsername
of
True
->
do
printDebug
"[G.A.N.Share.api]"
(
"demo users are not allowed to invite"
::
Text
)
pure
()
False
->
do
children
<-
findNodesId
nId
[
NodeCorpus
]
_
<-
case
List
.
null
children
of
True
->
do
printDebug
"[G.A.N.Share.api]"
(
"Invitation is enabled if you share a corpus at least"
::
Text
)
pure
0
False
->
do
printDebug
"[G.A.N.Share.api]"
(
"Your invitation is sent to: "
<>
user'
)
newUsers
[
user'
]
pure
()
pure
u
pure
u
fromIntegral
<$>
DB
.
shareNodeWith
(
ShareNodeWith_User
NodeFolderShared
(
UserName
user
))
nId
fromIntegral
<$>
DB
.
shareNodeWith
(
ShareNodeWith_User
NodeFolderShared
(
UserName
user
))
nId
api
nId2
(
SharePublicParams
nId1
)
=
api
_uId
nId2
(
SharePublicParams
nId1
)
=
fromIntegral
<$>
DB
.
shareNodeWith
(
ShareNodeWith_Node
NodeFolderPublic
nId1
)
nId2
fromIntegral
<$>
DB
.
shareNodeWith
(
ShareNodeWith_Node
NodeFolderPublic
nId1
)
nId2
...
...
src/Gargantext/Core/Text/List.hs
View file @
4c6051cc
...
@@ -98,7 +98,7 @@ buildNgramsOthersList user uCid groupParams (nt, MapListSize mapListSize) = do
...
@@ -98,7 +98,7 @@ buildNgramsOthersList user uCid groupParams (nt, MapListSize mapListSize) = do
socialLists'
::
FlowCont
Text
FlowListScores
socialLists'
::
FlowCont
Text
FlowListScores
<-
flowSocialList'
MySelfFirst
user
nt
(
FlowCont
Map
.
empty
<-
flowSocialList'
MySelfFirst
user
nt
(
FlowCont
Map
.
empty
$
Map
.
fromList
$
Map
.
fromList
$
List
.
zip
(
Map
.
keys
allTerms
)
$
List
.
zip
(
Map
.
keys
allTerms
)
(
List
.
cycle
[
mempty
])
(
List
.
cycle
[
mempty
])
)
)
let
let
...
@@ -136,7 +136,6 @@ buildNgramsTermsList :: ( HasNodeError err
...
@@ -136,7 +136,6 @@ buildNgramsTermsList :: ( HasNodeError err
buildNgramsTermsList
user
uCid
mCid
groupParams
(
nt
,
_mapListSize
)
=
do
buildNgramsTermsList
user
uCid
mCid
groupParams
(
nt
,
_mapListSize
)
=
do
-- | Filter 0 With Double
-- | Filter 0 With Double
-- Computing global speGen score
-- Computing global speGen score
allTerms
::
Map
Text
Double
<-
getTficf
uCid
mCid
nt
allTerms
::
Map
Text
Double
<-
getTficf
uCid
mCid
nt
...
@@ -171,6 +170,7 @@ buildNgramsTermsList user uCid mCid groupParams (nt, _mapListSize)= do
...
@@ -171,6 +170,7 @@ buildNgramsTermsList user uCid mCid groupParams (nt, _mapListSize)= do
-- Filter 1 With Set NodeId and SpeGen
-- Filter 1 With Set NodeId and SpeGen
selectedTerms
=
Set
.
toList
$
hasTerms
(
groupedMonoHead
<>
groupedMultHead
)
selectedTerms
=
Set
.
toList
$
hasTerms
(
groupedMonoHead
<>
groupedMultHead
)
-- TO remove (and remove HasNodeError instance)
-- TO remove (and remove HasNodeError instance)
userListId
<-
defaultList
uCid
userListId
<-
defaultList
uCid
masterListId
<-
defaultList
mCid
masterListId
<-
defaultList
mCid
...
@@ -214,7 +214,7 @@ buildNgramsTermsList user uCid mCid groupParams (nt, _mapListSize)= do
...
@@ -214,7 +214,7 @@ buildNgramsTermsList user uCid mCid groupParams (nt, _mapListSize)= do
(
monoScored
,
multScored
)
=
Map
.
partitionWithKey
(
\
t
_v
->
size
t
<
2
)
groupedTreeScores_SpeGen
(
monoScored
,
multScored
)
=
Map
.
partitionWithKey
(
\
t
_v
->
size
t
<
2
)
groupedTreeScores_SpeGen
-- filter with max score
-- filter with max score
partitionWithMaxScore
=
Map
.
partition
(
\
g
->
(
view
scored_genInc
$
view
gts'_score
g
)
partitionWithMaxScore
=
Map
.
partition
(
\
g
->
(
view
scored_genInc
$
view
gts'_score
g
)
>
(
view
scored_speExc
$
view
gts'_score
g
)
>
(
view
scored_speExc
$
view
gts'_score
g
)
)
)
...
@@ -228,8 +228,8 @@ buildNgramsTermsList user uCid mCid groupParams (nt, _mapListSize)= do
...
@@ -228,8 +228,8 @@ buildNgramsTermsList user uCid mCid groupParams (nt, _mapListSize)= do
inclSize
=
0.4
::
Double
inclSize
=
0.4
::
Double
exclSize
=
1
-
inclSize
exclSize
=
1
-
inclSize
splitAt'
n'
=
(
both
(
Map
.
fromList
))
.
(
List
.
splitAt
(
round
$
n'
*
listSizeLocal
))
splitAt'
n'
=
(
both
(
Map
.
fromList
))
.
(
List
.
splitAt
(
round
$
n'
*
listSizeLocal
))
sortOn
f
=
(
List
.
sortOn
(
Down
.
(
view
(
gts'_score
.
f
))
.
snd
))
.
Map
.
toList
sortOn
f
=
(
List
.
sortOn
(
Down
.
(
view
(
gts'_score
.
f
))
.
snd
))
.
Map
.
toList
monoInc_size
=
splitAt'
$
monoSize
*
inclSize
/
2
monoInc_size
=
splitAt'
$
monoSize
*
inclSize
/
2
...
...
src/Gargantext/Core/Text/List/Group/WithStem.hs
View file @
4c6051cc
...
@@ -67,7 +67,7 @@ groupWith :: GroupParams
...
@@ -67,7 +67,7 @@ groupWith :: GroupParams
->
Text
->
Text
->
Text
->
Text
groupWith
GroupIdentity
=
identity
groupWith
GroupIdentity
=
identity
groupWith
(
GroupParams
l
_m
_n
_
)
=
groupWith
(
GroupParams
l
_m
_n
_
)
=
Text
.
intercalate
" "
Text
.
intercalate
" "
.
map
(
stem
l
)
.
map
(
stem
l
)
-- . take n
-- . take n
...
@@ -81,7 +81,7 @@ groupWithStem_SetNodeId :: GroupParams
...
@@ -81,7 +81,7 @@ groupWithStem_SetNodeId :: GroupParams
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
->
FlowCont
Text
(
GroupedTreeScores
(
Set
NodeId
))
groupWithStem_SetNodeId
g
flc
groupWithStem_SetNodeId
g
flc
|
g
==
GroupIdentity
=
FlowCont
(
(
<>
)
|
g
==
GroupIdentity
=
FlowCont
(
(
<>
)
(
view
flc_scores
flc
)
(
view
flc_scores
flc
)
(
view
flc_cont
flc
)
(
view
flc_cont
flc
)
)
mempty
)
mempty
...
@@ -91,7 +91,7 @@ groupWithStem_Double :: GroupParams
...
@@ -91,7 +91,7 @@ groupWithStem_Double :: GroupParams
->
FlowCont
Text
(
GroupedTreeScores
Double
)
->
FlowCont
Text
(
GroupedTreeScores
Double
)
->
FlowCont
Text
(
GroupedTreeScores
Double
)
->
FlowCont
Text
(
GroupedTreeScores
Double
)
groupWithStem_Double
g
flc
groupWithStem_Double
g
flc
|
g
==
GroupIdentity
=
FlowCont
(
(
<>
)
|
g
==
GroupIdentity
=
FlowCont
(
(
<>
)
(
view
flc_scores
flc
)
(
view
flc_scores
flc
)
(
view
flc_cont
flc
)
(
view
flc_cont
flc
)
)
mempty
)
mempty
...
...
src/Gargantext/Core/Types/Individu.hs
View file @
4c6051cc
...
@@ -52,7 +52,7 @@ data NewUser a = NewUser { _nu_username :: Username
...
@@ -52,7 +52,7 @@ data NewUser a = NewUser { _nu_username :: Username
deriving
(
Show
)
deriving
(
Show
)
arbitraryUsername
::
[
Username
]
arbitraryUsername
::
[
Username
]
arbitraryUsername
=
[
"gargantua"
]
<>
users
arbitraryUsername
=
{- ["gargantua"] <> -}
users
where
where
users
=
zipWith
(
\
a
b
->
a
<>
(
pack
.
show
)
b
)
users
=
zipWith
(
\
a
b
->
a
<>
(
pack
.
show
)
b
)
(
repeat
"user"
)
([
1
..
20
]
::
[
Int
])
(
repeat
"user"
)
([
1
..
20
]
::
[
Int
])
...
@@ -68,12 +68,13 @@ toUserHash (NewUser u m (GargPassword p)) = do
...
@@ -68,12 +68,13 @@ toUserHash (NewUser u m (GargPassword p)) = do
h
<-
Auth
.
createPasswordHash
p
h
<-
Auth
.
createPasswordHash
p
pure
$
NewUser
u
m
h
pure
$
NewUser
u
m
h
-- TODO remove
arbitraryUsersHash
::
MonadIO
m
arbitraryUsersHash
::
MonadIO
m
=>
m
[
NewUser
HashPassword
]
=>
m
[
NewUser
HashPassword
]
arbitraryUsersHash
=
mapM
toUserHash
arbitraryUsers
arbitraryUsersHash
=
mapM
toUserHash
arbitrary
New
Users
arbitraryUsers
::
[
NewUser
GargPassword
]
arbitrary
New
Users
::
[
NewUser
GargPassword
]
arbitraryUsers
=
map
(
\
u
->
NewUser
u
(
u
<>
"@gargantext.org"
)
(
GargPassword
$
reverse
u
))
arbitrary
New
Users
=
map
(
\
u
->
NewUser
u
(
u
<>
"@gargantext.org"
)
(
GargPassword
$
reverse
u
))
arbitraryUsername
arbitraryUsername
src/Gargantext/Database/Action/User.hs
View file @
4c6051cc
...
@@ -31,7 +31,7 @@ getUserId u = do
...
@@ -31,7 +31,7 @@ getUserId u = do
maybeUser
<-
getUserId'
u
maybeUser
<-
getUserId'
u
case
maybeUser
of
case
maybeUser
of
Nothing
->
nodeError
NoUserFound
Nothing
->
nodeError
NoUserFound
Just
u
->
pure
u
Just
u
'
->
pure
u'
getUserId'
::
HasNodeError
err
getUserId'
::
HasNodeError
err
=>
User
=>
User
...
...
src/Gargantext/Database/Action/User/New.hs
View file @
4c6051cc
...
@@ -44,9 +44,10 @@ newUserQuick n = do
...
@@ -44,9 +44,10 @@ newUserQuick n = do
pass
<-
gargPass
pass
<-
gargPass
let
u
=
case
guessUserName
n
of
let
u
=
case
guessUserName
n
of
Just
(
u'
,
_m
)
->
u'
Just
(
u'
,
_m
)
->
u'
Nothing
->
panic
"Email invalid"
Nothing
->
panic
"
[G.D.A.U.N.newUserQuick]:
Email invalid"
pure
(
NewUser
u
n
(
GargPassword
pass
))
pure
(
NewUser
u
n
(
GargPassword
pass
))
------------------------------------------------------------------------
isEmail
::
Text
->
Bool
isEmail
::
Text
->
Bool
isEmail
=
((
==
)
2
)
.
List
.
length
.
(
splitOn
"@"
)
isEmail
=
((
==
)
2
)
.
List
.
length
.
(
splitOn
"@"
)
...
@@ -69,12 +70,17 @@ newUsers' address us = do
...
@@ -69,12 +70,17 @@ newUsers' address us = do
_
<-
liftBase
$
mapM
(
mail
Invitation
address
)
us
_
<-
liftBase
$
mapM
(
mail
Invitation
address
)
us
pure
r
pure
r
------------------------------------------------------------------------
------------------------------------------------------------------------
data
SendEmail
=
SendEmail
Bool
updateUser
::
HasNodeError
err
updateUser
::
HasNodeError
err
=>
Text
->
NewUser
GargPassword
->
Cmd
err
Int64
=>
SendEmail
->
Text
->
NewUser
GargPassword
->
Cmd
err
Int64
updateUser
address
u
=
do
updateUser
(
SendEmail
send
)
address
u
=
do
u'
<-
liftBase
$
toUserHash
u
u'
<-
liftBase
$
toUserHash
u
n
<-
updateUserDB
$
toUserWrite
u'
n
<-
updateUserDB
$
toUserWrite
u'
_
<-
liftBase
$
mail
Update
address
u
_
<-
case
send
of
True
->
liftBase
$
mail
Update
address
u
False
->
pure
()
pure
n
pure
n
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Database/Query/Table/User.hs
View file @
4c6051cc
...
@@ -24,7 +24,7 @@ module Gargantext.Database.Query.Table.User
...
@@ -24,7 +24,7 @@ module Gargantext.Database.Query.Table.User
,
updateUserDB
,
updateUserDB
,
queryUserTable
,
queryUserTable
,
getUser
,
getUser
,
insert
UsersDemo
,
insert
NewUsers
,
selectUsersLightWith
,
selectUsersLightWith
,
userWithUsername
,
userWithUsername
,
userWithId
,
userWithId
...
@@ -81,7 +81,7 @@ toUserWrite (NewUser u m (Auth.PasswordHash p)) =
...
@@ -81,7 +81,7 @@ toUserWrite (NewUser u m (Auth.PasswordHash p)) =
(
pgStrictText
"first_name"
)
(
pgStrictText
"first_name"
)
(
pgStrictText
"last_name"
)
(
pgStrictText
"last_name"
)
(
pgStrictText
m
)
(
pgStrictText
m
)
(
pgBool
True
)
(
pgBool
True
)
(
pgBool
True
)
Nothing
(
pgBool
True
)
Nothing
------------------------------------------------------------------
------------------------------------------------------------------
...
@@ -141,9 +141,9 @@ getUser u = userLightWithUsername u <$> usersLight
...
@@ -141,9 +141,9 @@ getUser u = userLightWithUsername u <$> usersLight
----------------------------------------------------------------------
----------------------------------------------------------------------
insert
UsersDemo
::
Cmd
err
Int64
insert
NewUsers
::
[
NewUser
GargPassword
]
->
Cmd
err
Int64
insert
UsersDemo
=
do
insert
NewUsers
newUsers
=
do
users
<-
liftBase
arbitraryUsersHash
users
<-
liftBase
$
mapM
toUserHash
newUsers
insertUsers
$
map
toUserWrite
users
insertUsers
$
map
toUserWrite
users
----------------------------------------------------------------------
----------------------------------------------------------------------
...
...
src/Gargantext/Prelude/Job.hs
View file @
4c6051cc
...
@@ -48,6 +48,8 @@ runJobLog num logStatus = do
...
@@ -48,6 +48,8 @@ runJobLog num logStatus = do
logStatus
jl
logStatus
jl
logRefSuccessF
ref
=
do
logRefSuccessF
ref
=
do
jl
<-
liftBase
$
readIORef
ref
jl
<-
liftBase
$
readIORef
ref
liftBase
$
writeIORef
ref
$
jobLogSuccess
jl
let
jl'
=
jobLogSuccess
jl
liftBase
$
writeIORef
ref
jl'
logStatus
jl'
getRefF
ref
=
do
getRefF
ref
=
do
liftBase
$
readIORef
ref
liftBase
$
readIORef
ref
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment