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
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
54a23c8e
Commit
54a23c8e
authored
Feb 09, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-ngrams-repo' of
ssh://delanoe.org/haskell-gargantext
into dev-ngrams-repo
parents
98e0a7ba
2d442b4a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
20 deletions
+59
-20
Main.hs
bin/gargantext-import/Main.hs
+13
-10
API.hs
src/Gargantext/API.hs
+8
-2
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+8
-0
Settings.hs
src/Gargantext/API/Settings.hs
+25
-3
Ngrams.hs
src/Gargantext/Database/Schema/Ngrams.hs
+3
-0
Node.hs
src/Gargantext/Database/Types/Node.hs
+2
-5
No files found.
bin/gargantext-import/Main.hs
View file @
54a23c8e
...
@@ -19,6 +19,7 @@ Import a corpus binary.
...
@@ -19,6 +19,7 @@ Import a corpus binary.
module
Main
where
module
Main
where
import
Control.Exception
(
finally
)
import
Servant
(
ServantErr
)
import
Servant
(
ServantErr
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Database.Flow
(
FlowCmdM
,
flowCorpus
)
import
Gargantext.Database.Flow
(
FlowCmdM
,
flowCorpus
)
...
@@ -27,7 +28,7 @@ import Gargantext.Database.Utils (Cmd, connectGargandb, runCmdDev)
...
@@ -27,7 +28,7 @@ import Gargantext.Database.Utils (Cmd, connectGargandb, runCmdDev)
import
Gargantext.Database.Types.Node
(
CorpusId
)
import
Gargantext.Database.Types.Node
(
CorpusId
)
--import Gargantext.Database.Schema.User (insertUsers, gargantuaUser, simpleUser)
--import Gargantext.Database.Schema.User (insertUsers, gargantuaUser, simpleUser)
import
Gargantext.API.Node
()
-- instances
import
Gargantext.API.Node
()
-- instances
import
Gargantext.API.Settings
(
newDevEnvWith
,
DevEnv
)
import
Gargantext.API.Settings
(
newDevEnvWith
,
cleanEnv
,
DevEnv
)
import
System.Environment
(
getArgs
)
import
System.Environment
(
getArgs
)
main
::
IO
()
main
::
IO
()
...
@@ -36,6 +37,7 @@ main = do
...
@@ -36,6 +37,7 @@ main = do
env
<-
newDevEnvWith
iniPath
env
<-
newDevEnvWith
iniPath
(
do
{-let createUsers :: Cmd ServantErr Int64
{-let createUsers :: Cmd ServantErr Int64
createUsers = insertUsers [gargantuaUser,simpleUser]
createUsers = insertUsers [gargantuaUser,simpleUser]
_ <- runCmdDev env createUsers
_ <- runCmdDev env createUsers
...
@@ -43,7 +45,8 @@ main = do
...
@@ -43,7 +45,8 @@ main = do
let
cmd
::
FlowCmdM
DevEnv
ServantErr
m
=>
m
CorpusId
let
cmd
::
FlowCmdM
DevEnv
ServantErr
m
=>
m
CorpusId
cmd
=
flowCorpus
CsvHalFormat
corpusPath
(
cs
name
)
cmd
=
flowCorpus
CsvHalFormat
corpusPath
(
cs
name
)
r
<-
runCmdDev
env
cmd
_
<-
runCmdDev
env
cmd
pure
()
pure
()
)
`
finally
`
cleanEnv
env
src/Gargantext/API.hs
View file @
54a23c8e
...
@@ -44,6 +44,7 @@ import GHC.Generics (D1, Meta (..), Rep)
...
@@ -44,6 +44,7 @@ import GHC.Generics (D1, Meta (..), Rep)
import
GHC.TypeLits
(
AppendSymbol
,
Symbol
)
import
GHC.TypeLits
(
AppendSymbol
,
Symbol
)
import
Control.Lens
import
Control.Lens
import
Control.Exception
(
finally
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Control.Monad.Reader
(
runReaderT
)
import
Control.Monad.Reader
(
runReaderT
)
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
...
@@ -72,7 +73,7 @@ import Gargantext.Prelude
...
@@ -72,7 +73,7 @@ import Gargantext.Prelude
import
Gargantext.API.FrontEnd
(
FrontEndAPI
,
frontEndServer
)
import
Gargantext.API.FrontEnd
(
FrontEndAPI
,
frontEndServer
)
import
Gargantext.API.Auth
(
AuthRequest
,
AuthResponse
,
auth
)
import
Gargantext.API.Auth
(
AuthRequest
,
AuthResponse
,
auth
)
import
Gargantext.API.Ngrams
(
HasRepoVar
)
import
Gargantext.API.Ngrams
(
HasRepoVar
(
..
)
)
import
Gargantext.API.Node
(
GargServer
import
Gargantext.API.Node
(
GargServer
,
Roots
,
roots
,
Roots
,
roots
,
NodeAPI
,
nodeAPI
,
NodeAPI
,
nodeAPI
...
@@ -369,6 +370,11 @@ portRouteInfo port = do
...
@@ -369,6 +370,11 @@ portRouteInfo port = do
T
.
putStrLn
$
"http://localhost:"
<>
toUrlPiece
port
<>
"/index.html"
T
.
putStrLn
$
"http://localhost:"
<>
toUrlPiece
port
<>
"/index.html"
T
.
putStrLn
$
"http://localhost:"
<>
toUrlPiece
port
<>
"/swagger-ui"
T
.
putStrLn
$
"http://localhost:"
<>
toUrlPiece
port
<>
"/swagger-ui"
stopGargantext
::
HasRepoVar
env
=>
env
->
IO
()
stopGargantext
env
=
do
T
.
putStrLn
"----- Stopping gargantext -----"
cleanEnv
env
-- | startGargantext takes as parameters port number and Ini file.
-- | startGargantext takes as parameters port number and Ini file.
startGargantext
::
PortNumber
->
FilePath
->
IO
()
startGargantext
::
PortNumber
->
FilePath
->
IO
()
startGargantext
port
file
=
do
startGargantext
port
file
=
do
...
@@ -376,7 +382,7 @@ startGargantext port file = do
...
@@ -376,7 +382,7 @@ startGargantext port file = do
portRouteInfo
port
portRouteInfo
port
app
<-
makeApp
env
app
<-
makeApp
env
mid
<-
makeDevMiddleware
mid
<-
makeDevMiddleware
run
port
$
mid
app
run
port
(
mid
app
)
`
finally
`
stopGargantext
env
startGargantextMock
::
PortNumber
->
IO
()
startGargantextMock
::
PortNumber
->
IO
()
startGargantextMock
port
=
do
startGargantextMock
port
=
do
...
...
src/Gargantext/API/Ngrams.hs
View file @
54a23c8e
...
@@ -568,6 +568,14 @@ data Repo s p = Repo
...
@@ -568,6 +568,14 @@ data Repo s p = Repo
,
_r_history
::
[
p
]
,
_r_history
::
[
p
]
-- ^ first patch in the list is the most recent
-- ^ first patch in the list is the most recent
}
}
deriving
(
Generic
)
instance
(
FromJSON
s
,
FromJSON
p
)
=>
FromJSON
(
Repo
s
p
)
where
parseJSON
=
genericParseJSON
$
unPrefix
"_r_"
instance
(
ToJSON
s
,
ToJSON
p
)
=>
ToJSON
(
Repo
s
p
)
where
toJSON
=
genericToJSON
$
unPrefix
"_r_"
toEncoding
=
genericToEncoding
$
unPrefix
"_r_"
makeLenses
''
R
epo
makeLenses
''
R
epo
...
...
src/Gargantext/API/Settings.hs
View file @
54a23c8e
...
@@ -22,16 +22,18 @@ Portability : POSIX
...
@@ -22,16 +22,18 @@ Portability : POSIX
module
Gargantext.API.Settings
module
Gargantext.API.Settings
where
where
import
System.Directory
import
System.Log.FastLogger
import
System.Log.FastLogger
import
GHC.Enum
import
GHC.Enum
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Prelude
(
Bounded
())
import
Prelude
(
Bounded
()
,
fail
)
import
System.Environment
(
lookupEnv
)
import
System.Environment
(
lookupEnv
)
import
System.IO
(
FilePath
)
import
System.IO
(
FilePath
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Network.HTTP.Client
(
Manager
)
import
Network.HTTP.Client
(
Manager
)
import
Network.HTTP.Client.TLS
(
newTlsManager
)
import
Network.HTTP.Client.TLS
(
newTlsManager
)
import
Data.Aeson
import
Data.Maybe
(
fromMaybe
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Either
(
either
)
import
Data.Either
(
either
)
import
Data.Text
import
Data.Text
...
@@ -50,7 +52,7 @@ import Control.Monad.Logger
...
@@ -50,7 +52,7 @@ import Control.Monad.Logger
import
Control.Lens
import
Control.Lens
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Database.Utils
(
databaseParameters
,
HasConnection
(
..
))
import
Gargantext.Database.Utils
(
databaseParameters
,
HasConnection
(
..
))
import
Gargantext.API.Ngrams
(
NgramsRepo
,
HasRepoVar
(
..
),
initMockRepo
)
import
Gargantext.API.Ngrams
(
NgramsRepo
,
HasRepoVar
(
..
),
initMockRepo
,
r_version
)
import
Gargantext.API.Orchestrator.Types
import
Gargantext.API.Orchestrator.Types
type
PortNumber
=
Int
type
PortNumber
=
Int
...
@@ -152,6 +154,26 @@ data MockEnv = MockEnv
...
@@ -152,6 +154,26 @@ data MockEnv = MockEnv
makeLenses
''
M
ockEnv
makeLenses
''
M
ockEnv
repoSnapshot
::
FilePath
repoSnapshot
=
"repo.json"
readRepo
::
IO
(
MVar
NgramsRepo
)
readRepo
=
do
repoExists
<-
doesFileExist
repoSnapshot
newMVar
=<<
if
repoExists
then
do
e_repo
<-
eitherDecodeFileStrict
repoSnapshot
repo
<-
either
fail
pure
e_repo
let
archive
=
repoSnapshot
<>
".v"
<>
show
(
repo
^.
r_version
)
renameFile
repoSnapshot
archive
pure
repo
else
pure
initMockRepo
cleanEnv
::
HasRepoVar
env
=>
env
->
IO
()
cleanEnv
env
=
encodeFile
repoSnapshot
=<<
readMVar
(
env
^.
repoVar
)
newEnv
::
PortNumber
->
FilePath
->
IO
Env
newEnv
::
PortNumber
->
FilePath
->
IO
Env
newEnv
port
file
=
do
newEnv
port
file
=
do
manager
<-
newTlsManager
manager
<-
newTlsManager
...
@@ -161,7 +183,7 @@ newEnv port file = do
...
@@ -161,7 +183,7 @@ newEnv port file = do
self_url
<-
parseBaseUrl
$
"http://0.0.0.0:"
<>
show
port
self_url
<-
parseBaseUrl
$
"http://0.0.0.0:"
<>
show
port
param
<-
databaseParameters
file
param
<-
databaseParameters
file
conn
<-
connect
param
conn
<-
connect
param
repo_var
<-
newMVar
initMock
Repo
repo_var
<-
read
Repo
scrapers_env
<-
newJobEnv
defaultSettings
manager
scrapers_env
<-
newJobEnv
defaultSettings
manager
logger
<-
newStderrLoggerSet
defaultBufSize
logger
<-
newStderrLoggerSet
defaultBufSize
pure
$
Env
pure
$
Env
...
...
src/Gargantext/Database/Schema/Ngrams.hs
View file @
54a23c8e
...
@@ -28,6 +28,7 @@ module Gargantext.Database.Schema.Ngrams where
...
@@ -28,6 +28,7 @@ module Gargantext.Database.Schema.Ngrams where
import
Data.Aeson
(
FromJSON
,
FromJSONKey
)
import
Data.Aeson
(
FromJSON
,
FromJSONKey
)
import
Control.Lens
(
makeLenses
,
view
,
over
)
import
Control.Lens
(
makeLenses
,
view
,
over
)
import
Control.Monad
(
mzero
)
import
Control.Monad
(
mzero
)
import
Data.Aeson
import
Data.ByteString.Internal
(
ByteString
)
import
Data.ByteString.Internal
(
ByteString
)
import
Data.Map
(
Map
,
fromList
,
lookup
,
fromListWith
)
import
Data.Map
(
Map
,
fromList
,
lookup
,
fromListWith
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
...
@@ -105,6 +106,8 @@ data NgramsType = Authors | Institutes | Sources | NgramsTerms
...
@@ -105,6 +106,8 @@ data NgramsType = Authors | Institutes | Sources | NgramsTerms
instance
FromJSON
NgramsType
instance
FromJSON
NgramsType
instance
FromJSONKey
NgramsType
instance
FromJSONKey
NgramsType
instance
ToJSON
NgramsType
instance
ToJSONKey
NgramsType
newtype
NgramsTypeId
=
NgramsTypeId
Int
newtype
NgramsTypeId
=
NgramsTypeId
Int
deriving
(
Eq
,
Show
,
Ord
,
Num
)
deriving
(
Eq
,
Show
,
Ord
,
Num
)
...
...
src/Gargantext/Database/Types/Node.hs
View file @
54a23c8e
...
@@ -60,7 +60,7 @@ import Gargantext.Core.Utils.Prefix (unPrefix)
...
@@ -60,7 +60,7 @@ import Gargantext.Core.Utils.Prefix (unPrefix)
--import Gargantext.Database.Utils
--import Gargantext.Database.Utils
------------------------------------------------------------------------
------------------------------------------------------------------------
newtype
NodeId
=
NodeId
Int
newtype
NodeId
=
NodeId
Int
deriving
(
Show
,
Read
,
Generic
,
Num
,
Eq
,
Ord
,
Enum
)
deriving
(
Show
,
Read
,
Generic
,
Num
,
Eq
,
Ord
,
Enum
,
ToJSONKey
,
FromJSONKey
,
ToJSON
,
FromJSON
)
instance
ToField
NodeId
where
instance
ToField
NodeId
where
toField
(
NodeId
n
)
=
toField
n
toField
(
NodeId
n
)
=
toField
n
...
@@ -71,9 +71,6 @@ instance FromField NodeId where
...
@@ -71,9 +71,6 @@ instance FromField NodeId where
if
(
n
::
Int
)
>
0
then
return
$
NodeId
n
if
(
n
::
Int
)
>
0
then
return
$
NodeId
n
else
mzero
else
mzero
instance
ToJSON
NodeId
instance
FromJSON
NodeId
instance
FromJSONKey
NodeId
instance
ToSchema
NodeId
instance
ToSchema
NodeId
instance
FromHttpApiData
NodeId
where
instance
FromHttpApiData
NodeId
where
...
...
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