Commit c97234ed authored by Alexandre Delanoë's avatar Alexandre Delanoë

merge

parents 2f308bcf abf437c8
Pipeline #5958 passed with stages
in 103 minutes and 15 seconds
## Version 0.0.6.9.9.9.9.1 [RELEASE CANDIDATE 007]
* [FRONT][FIX][In Document View: show Institute field of the document (#629)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/629)
* [BACK][FIX] Cabal optim
* [BACK][FIX][duckling fork (#319)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/319)
* [BACK][FIX][haskell-opaleye fork (#317)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/317)
* [BACK][FIX][[Node type/API GQL] Extend a little the node GQL query to have an extra "node_type" (or similar) so that we can extend the Purescript Node type with the value form the backend (#336)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/336)
* [BACK][DOC][Welcome: Door To enter the project (#177)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/177)
## Version 0.0.6.9.9.9.9 [RELEASE CANDIDATE 007] ## Version 0.0.6.9.9.9.9 [RELEASE CANDIDATE 007]
* [FRONT][FIX][[Node Documents] In the settings popin, remove the upload button (and also delete button) (#634)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/634) * [FRONT][FIX][[Node Documents] In the settings popin, remove the upload button (and also delete button) (#634)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/634)
......
...@@ -18,8 +18,8 @@ fi ...@@ -18,8 +18,8 @@ fi
# with the `sha256sum` result calculated on the `cabal.project` and # with the `sha256sum` result calculated on the `cabal.project` and
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI # `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# cache can kick in. # cache can kick in.
expected_cabal_project_hash="f77aa2eb8821ee1ff010402fc6f64b3c87b01045e3c9d31b4fa264e9f57e6fe3" expected_cabal_project_hash="0d3f7f5beed88c1afe95e0df8a91080440ba59049f3610bf2343132635038d22"
expected_cabal_project_freeze_hash="a88c2d091ee6223b64fb5dd38e71ab8379710a2aa716d2467f318789e4d75589" expected_cabal_project_freeze_hash="9b2cac3a02e9b129bd80253fc407782bf10c7ed62ed21be41c720d30ed17ef53"
cabal --store-dir=$STORE_DIR v2-build --dry-run cabal --store-dir=$STORE_DIR v2-build --dry-run
cabal2stack --system-ghc --allow-newer --resolver lts-21.17 --resolver-file devops/stack/lts-21.17.yaml -o stack.yaml cabal2stack --system-ghc --allow-newer --resolver lts-21.17 --resolver-file devops/stack/lts-21.17.yaml -o stack.yaml
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
index-state: 2023-12-10T10:34:46Z index-state: 2023-12-10T10:34:46Z
with-compiler: ghc-9.4.7 with-compiler: ghc-9.4.7
optimization: 2
packages: packages:
./ ./
...@@ -27,13 +28,8 @@ source-repository-package ...@@ -27,13 +28,8 @@ source-repository-package
source-repository-package source-repository-package
type: git type: git
location: https://github.com/adinapoli/duckling.git location: https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git
tag: 23603a832117e5352d5b0fb9bb1110228324b35a tag: cb07b604bfb7a22aa21dd8918de5cb65c8a4bdf1
source-repository-package
type: git
location: https://github.com/garganscript/haskell-opaleye.git
tag: 6cf1bcfe215143efac17919cfd0abdd60e0f717c
source-repository-package source-repository-package
type: git type: git
...@@ -42,11 +38,6 @@ source-repository-package ...@@ -42,11 +38,6 @@ source-repository-package
subdir: llvm-hs subdir: llvm-hs
llvm-hs-pure llvm-hs-pure
source-repository-package
type: git
location: https://github.com/adinapoli/text16-compat.git
tag: 85533b5d597e6fc5498411b4bcfc76380ec80d71
source-repository-package source-repository-package
type: git type: git
location: https://github.com/alpmestan/accelerate-arithmetic.git location: https://github.com/alpmestan/accelerate-arithmetic.git
......
...@@ -126,8 +126,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -126,8 +126,6 @@ constraints: any.Cabal ==3.8.1.0,
any.conduit-zstd ==0.0.2.0, any.conduit-zstd ==0.0.2.0,
any.connection ==0.3.1, any.connection ==0.3.1,
any.constraints ==0.13.4, any.constraints ==0.13.4,
any.constraints-extras ==0.4.0.0,
constraints-extras +build-readme,
any.containers ==0.6.7, any.containers ==0.6.7,
any.contravariant ==1.5.5, any.contravariant ==1.5.5,
contravariant +semigroups +statevar +tagged, contravariant +semigroups +statevar +tagged,
...@@ -169,7 +167,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -169,7 +167,6 @@ constraints: any.Cabal ==3.8.1.0,
any.dec ==0.0.5, any.dec ==0.0.5,
any.deepseq ==1.4.8.0, any.deepseq ==1.4.8.0,
any.dense-linear-algebra ==0.1.0.0, any.dense-linear-algebra ==0.1.0.0,
any.dependent-sum ==0.7.1.0,
any.deriving-aeson ==0.2.9, any.deriving-aeson ==0.2.9,
any.digest ==0.0.1.7, any.digest ==0.0.1.7,
digest +pkg-config, digest +pkg-config,
...@@ -183,7 +180,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -183,7 +180,6 @@ constraints: any.Cabal ==3.8.1.0,
any.doctemplates ==0.11, any.doctemplates ==0.11,
any.double-conversion ==2.0.4.2, any.double-conversion ==2.0.4.2,
double-conversion -developer +embedded_double_conversion, double-conversion -developer +embedded_double_conversion,
any.duckling ==0.2.0.0,
any.easy-file ==0.2.5, any.easy-file ==0.2.5,
any.eigen ==3.3.7.0, any.eigen ==3.3.7.0,
any.either ==5.0.2, any.either ==5.0.2,
...@@ -196,7 +192,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -196,7 +192,6 @@ constraints: any.Cabal ==3.8.1.0,
any.epo-api-client ==0.1.0.0, any.epo-api-client ==0.1.0.0,
any.erf ==2.0.0.0, any.erf ==2.0.0.0,
any.exceptions ==0.10.5, any.exceptions ==0.10.5,
any.extensible-exceptions ==0.1.1.4,
any.extra ==1.7.14, any.extra ==1.7.14,
any.fail ==4.9.0.0, any.fail ==4.9.0.0,
any.fast-logger ==3.2.2, any.fast-logger ==3.2.2,
...@@ -219,8 +214,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -219,8 +214,6 @@ constraints: any.Cabal ==3.8.1.0,
any.fullstop ==0.1.4, any.fullstop ==0.1.4,
any.gargantext-graph ==0.1.0.0, any.gargantext-graph ==0.1.0.0,
any.gargantext-prelude ==0.1.0.0, any.gargantext-prelude ==0.1.0.0,
any.generic-deriving ==1.14.5,
generic-deriving +base-4-9,
any.generic-monoid ==0.1.0.1, any.generic-monoid ==0.1.0.1,
any.generically ==0.1.1, any.generically ==0.1.1,
any.generics-sop ==0.5.1.3, any.generics-sop ==0.5.1.3,
...@@ -311,9 +304,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -311,9 +304,6 @@ constraints: any.Cabal ==3.8.1.0,
any.integer-logarithms ==1.0.3.1, any.integer-logarithms ==1.0.3.1,
integer-logarithms -check-bounds +integer-gmp, integer-logarithms -check-bounds +integer-gmp,
any.invariant ==0.6.2, any.invariant ==0.6.2,
any.io-streams ==1.5.2.2,
io-streams +network -nointeractivetests +zlib,
any.io-streams-haproxy ==1.0.1.0,
any.iproute ==1.7.12, any.iproute ==1.7.12,
any.ipynb ==0.2, any.ipynb ==0.2,
any.ipython-kernel ==0.11.0.0, any.ipython-kernel ==0.11.0.0,
...@@ -393,6 +383,7 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -393,6 +383,7 @@ constraints: any.Cabal ==3.8.1.0,
any.old-locale ==1.0.0.7, any.old-locale ==1.0.0.7,
any.old-time ==1.1.0.3, any.old-time ==1.1.0.3,
any.opaleye ==0.9.6.1, any.opaleye ==0.9.6.1,
any.opaleye-textsearch ==0.1.0.0,
any.openalex ==0.1.0.0, any.openalex ==0.1.0.0,
any.optics-core ==0.4.1.1, any.optics-core ==0.4.1.1,
optics-core -explicit-generic-labels, optics-core -explicit-generic-labels,
...@@ -457,7 +448,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -457,7 +448,6 @@ constraints: any.Cabal ==3.8.1.0,
any.random-shuffle ==0.0.4, any.random-shuffle ==0.0.4,
any.raw-strings-qq ==1.1, any.raw-strings-qq ==1.1,
any.rdf4h ==3.1.1, any.rdf4h ==3.1.1,
any.readable ==0.3.1,
any.recover-rtti ==0.4.3, any.recover-rtti ==0.4.3,
any.recv ==0.1.0, any.recv ==0.1.0,
any.refact ==0.3.0.2, any.refact ==0.3.0.2,
...@@ -465,8 +455,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -465,8 +455,6 @@ constraints: any.Cabal ==3.8.1.0,
reflection -slow +template-haskell, reflection -slow +template-haskell,
any.regex-base ==0.94.0.2, any.regex-base ==0.94.0.2,
any.regex-compat ==0.95.2.1, any.regex-compat ==0.95.2.1,
any.regex-pcre ==0.95.0.0,
regex-pcre +pkg-config,
any.regex-posix ==0.96.0.1, any.regex-posix ==0.96.0.1,
regex-posix -_regex-posix-clib, regex-posix -_regex-posix-clib,
any.regex-tdfa ==1.3.2.2, any.regex-tdfa ==1.3.2.2,
...@@ -534,10 +522,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -534,10 +522,6 @@ constraints: any.Cabal ==3.8.1.0,
any.skylighting-format-latex ==0.1, any.skylighting-format-latex ==0.1,
any.smallcheck ==1.2.1.1, any.smallcheck ==1.2.1.1,
any.smtp-mail ==0.3.0.0, any.smtp-mail ==0.3.0.0,
any.snap-core ==1.0.5.1,
snap-core -debug +network-uri -portable,
any.snap-server ==1.1.2.1,
snap-server -build-pong -build-testserver -debug -openssl -portable,
any.socks ==0.6.1, any.socks ==0.6.1,
any.some ==1.0.4.1, any.some ==1.0.4.1,
some +newtype-unsafe, some +newtype-unsafe,
...@@ -589,10 +573,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -589,10 +573,6 @@ constraints: any.Cabal ==3.8.1.0,
text-metrics -dev, text-metrics -dev,
any.text-short ==0.1.5, any.text-short ==0.1.5,
text-short -asserts, text-short -asserts,
any.text-show ==3.10.4,
text-show +base-4-9 +integer-gmp +new-functor-classes +template-haskell-2-11,
any.text16-compat ==0.1.0.0,
text16-compat -enable-golden-test-generation,
any.tf-random ==0.5, any.tf-random ==0.5,
any.th-abstraction ==0.4.5.0, any.th-abstraction ==0.4.5.0,
any.th-compat ==0.1.4, any.th-compat ==0.1.4,
...@@ -609,7 +589,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -609,7 +589,6 @@ constraints: any.Cabal ==3.8.1.0,
any.time-locale-compat ==0.1.1.5, any.time-locale-compat ==0.1.1.5,
time-locale-compat -old-locale, time-locale-compat -old-locale,
any.time-manager ==0.0.1, any.time-manager ==0.0.1,
any.timezone-olson ==0.2.1,
any.timezone-series ==0.1.13, any.timezone-series ==0.1.13,
any.tls ==1.6.0, any.tls ==1.6.0,
tls +compat -hans +network, tls +compat -hans +network,
...@@ -700,7 +679,6 @@ constraints: any.Cabal ==3.8.1.0, ...@@ -700,7 +679,6 @@ constraints: any.Cabal ==3.8.1.0,
zip-archive -executable, zip-archive -executable,
any.zlib ==0.6.3.0, any.zlib ==0.6.3.0,
zlib -bundled-c-zlib -non-blocking-ffi -pkg-config, zlib -bundled-c-zlib -non-blocking-ffi -pkg-config,
any.zlib-bindings ==0.1.1.5,
any.zstd ==0.1.3.0, any.zstd ==0.1.3.0,
zstd +standalone zstd +standalone
index-state: hackage.haskell.org 2023-12-10T10:34:46Z index-state: hackage.haskell.org 2023-12-10T10:34:46Z
...@@ -29,7 +29,7 @@ USER 1000 ...@@ -29,7 +29,7 @@ USER 1000
RUN stack install aeson aeson-lens aeson-pretty array \ RUN stack install aeson aeson-lens aeson-pretty array \
blaze-html blaze-markup bytestring \ blaze-html blaze-markup bytestring \
conduit conduit-extra containers \ conduit conduit-extra containers \
deepseq directory duckling \ deepseq directory \
ekg-core ekg-json exceptions \ ekg-core ekg-json exceptions \
fgl filepath formatting \ fgl filepath formatting \
hashable hsparql http-api-data http-client http-client-tls http-conduit \ hashable hsparql http-api-data http-client http-client-tls http-conduit \
......
...@@ -5,7 +5,7 @@ cabal-version: 3.4 ...@@ -5,7 +5,7 @@ cabal-version: 3.4
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: gargantext name: gargantext
version: 0.0.6.9.9.9.9 version: 0.0.6.9.9.9.9.1
synopsis: Search, map, share synopsis: Search, map, share
description: Please see README.md description: Please see README.md
category: Data category: Data
...@@ -74,7 +74,6 @@ common defaults ...@@ -74,7 +74,6 @@ common defaults
build-depends: build-depends:
base >=4.7 && <5 base >=4.7 && <5
optimization: 2
common optimized common optimized
ghc-options: ghc-options:
-O2 -O2
...@@ -496,7 +495,6 @@ library ...@@ -496,7 +495,6 @@ library
, deepseq ^>= 1.4.4.0 , deepseq ^>= 1.4.4.0
, directory ^>= 1.3.6.0 , directory ^>= 1.3.6.0
, discrimination >= 0.5 , discrimination >= 0.5
, duckling ^>= 0.2.0.0
, ekg-core ^>= 0.1.1.7 , ekg-core ^>= 0.1.1.7
, ekg-json ^>= 0.1.0.7 , ekg-json ^>= 0.1.0.7
, epo-api-client , epo-api-client
...@@ -558,6 +556,7 @@ library ...@@ -558,6 +556,7 @@ library
, natural-transformation ^>= 0.4 , natural-transformation ^>= 0.4
, network-uri ^>= 2.6.4.1 , network-uri ^>= 2.6.4.1
, opaleye ^>= 0.9.6.1 , opaleye ^>= 0.9.6.1
, opaleye-textsearch >= 0.1.0.0
, openalex , openalex
, pandoc ^>= 2.14.0.3 , pandoc ^>= 2.14.0.3
, parallel ^>= 3.2.2.0 , parallel ^>= 3.2.2.0
...@@ -828,7 +827,6 @@ executable gargantext-server ...@@ -828,7 +827,6 @@ executable gargantext-server
, text ^>= 1.2.4.1 , text ^>= 1.2.4.1
, unordered-containers ^>= 0.2.16.0 , unordered-containers ^>= 0.2.16.0
, vector ^>= 0.7.3 , vector ^>= 0.7.3
optimization: 2
executable gargantext-upgrade executable gargantext-upgrade
import: import:
...@@ -906,7 +904,6 @@ test-suite garg-test-tasty ...@@ -906,7 +904,6 @@ test-suite garg-test-tasty
, crawlerArxiv , crawlerArxiv
, cryptohash , cryptohash
, directory , directory
, duckling ^>= 0.2.0.0
, extra ^>= 1.7.9 , extra ^>= 1.7.9
, fast-logger ^>= 3.0.5 , fast-logger ^>= 3.0.5
, fmt , fmt
...@@ -1002,7 +999,6 @@ test-suite garg-test-hspec ...@@ -1002,7 +999,6 @@ test-suite garg-test-hspec
, conduit ^>= 1.3.4.2 , conduit ^>= 1.3.4.2
, containers ^>= 0.6.5.1 , containers ^>= 0.6.5.1
, crawlerArxiv , crawlerArxiv
, duckling ^>= 0.2.0.0
, extra ^>= 1.7.9 , extra ^>= 1.7.9
, fast-logger ^>= 3.0.5 , fast-logger ^>= 3.0.5
, fmt , fmt
...@@ -1078,7 +1074,6 @@ executable gargantext-phylo-profile ...@@ -1078,7 +1074,6 @@ executable gargantext-phylo-profile
Common Common
hs-source-dirs: hs-source-dirs:
bin/gargantext-phylo-profile bin/gargantext-phylo/Phylo bin/gargantext-phylo-profile bin/gargantext-phylo/Phylo
default-extensions: GHC2021
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N -O2 -Wmissing-signatures ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N -O2 -Wmissing-signatures
build-depends: build-depends:
base base
...@@ -1093,7 +1088,7 @@ executable gargantext-phylo-profile ...@@ -1093,7 +1088,7 @@ executable gargantext-phylo-profile
, split , split
, vector , vector
, directory , directory
default-language: Haskell2010 default-language: GHC2021
executable garg-golden-file-diff executable garg-golden-file-diff
import: import:
......
...@@ -85,9 +85,13 @@ startGargantext mode port file = withLoggerHoisted mode $ \logger -> do ...@@ -85,9 +85,13 @@ startGargantext mode port file = withLoggerHoisted mode $ \logger -> do
portRouteInfo :: PortNumber -> IO () portRouteInfo :: PortNumber -> IO ()
portRouteInfo port = do portRouteInfo port = do
putStrLn " ----Main Routes----- " putStrLn "=========================================================================================================="
putStrLn $ "http://localhost:" <> toUrlPiece port <> "/index.html" putStrLn " GarganText Main Routes"
putStrLn $ "http://localhost:" <> toUrlPiece port <> "/swagger-ui" putStrLn "=========================================================================================================="
putStrLn $ " - Web GarganText Frontend..................: " <> "http://localhost:" <> toUrlPiece port <> "/index.html"
putStrLn $ " - Swagger UI (API documentation)...........: " <> "http://localhost:" <> toUrlPiece port <> "/swagger-ui"
putStrLn $ " - Playground GraphQL (API documentation)...: " <> "http://localhost:" <> toUrlPiece port <> "/gql"
putStrLn "=========================================================================================================="
-- | Stops the gargantext server and cancels all the periodic actions -- | Stops the gargantext server and cancels all the periodic actions
-- scheduled to run up to that point. -- scheduled to run up to that point.
......
...@@ -22,6 +22,7 @@ import Gargantext.API.Admin.Auth.Types ...@@ -22,6 +22,7 @@ import Gargantext.API.Admin.Auth.Types
import Gargantext.API.Auth.PolicyCheck import Gargantext.API.Auth.PolicyCheck
import Gargantext.API.GraphQL.PolicyCheck (withPolicy) import Gargantext.API.GraphQL.PolicyCheck (withPolicy)
import Gargantext.API.GraphQL.Types import Gargantext.API.GraphQL.Types
import Gargantext.Core
import Gargantext.Database.Admin.Types.Node (NodeType) import Gargantext.Database.Admin.Types.Node (NodeType)
import Gargantext.Database.Admin.Types.Node qualified as NN import Gargantext.Database.Admin.Types.Node qualified as NN
import Gargantext.Database.Prelude (CmdCommon) -- , JSONB) import Gargantext.Database.Prelude (CmdCommon) -- , JSONB)
...@@ -43,6 +44,7 @@ data Node = Node ...@@ -43,6 +44,7 @@ data Node = Node
, name :: Text , name :: Text
, parent_id :: Maybe Int , parent_id :: Maybe Int
, type_id :: Int , type_id :: Int
, node_type :: Maybe NodeType
} deriving (Show, Generic, GQLType) } deriving (Show, Generic, GQLType)
data CorpusArgs data CorpusArgs
...@@ -113,10 +115,14 @@ dbParentNodes node_id parent_type = do ...@@ -113,10 +115,14 @@ dbParentNodes node_id parent_type = do
pure [toNode node] pure [toNode node]
toNode :: NN.Node json -> Node toNode :: NN.Node json -> Node
toNode N.Node { .. } = Node { id = NN.unNodeId _node_id toNode N.Node { .. } = Node { id = nid
, name = _node_name , name = _node_name
, parent_id = NN.unNodeId <$> _node_parent_id , parent_id = NN.unNodeId <$> _node_parent_id
, type_id = _node_typename } , type_id = _node_typename
, node_type = lookupDBid _node_typename
}
where
nid = NN.unNodeId _node_id
toCorpus :: NN.Node Value -> Corpus toCorpus :: NN.Node Value -> Corpus
toCorpus N.Node { .. } = Corpus { id = NN.unNodeId _node_id toCorpus N.Node { .. } = Corpus { id = NN.unNodeId _node_id
......
...@@ -18,30 +18,21 @@ DGP.parseDateRaw DGP.FR "12 avril 2010" == "2010-04-12T00:00:00.000+00:00" ...@@ -18,30 +18,21 @@ DGP.parseDateRaw DGP.FR "12 avril 2010" == "2010-04-12T00:00:00.000+00:00"
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
module Gargantext.Core.Text.Corpus.Parsers.Date module Gargantext.Core.Text.Corpus.Parsers.Date (
{-(parse, parseRaw, dateSplit, Year, Month, Day)-} dateSplit
where , mDateSplit
, defaultDay
, defaultUTCTime
, split'
) where
import Data.Aeson (Value)
import Data.Aeson qualified as Json
import Data.Aeson.KeyMap as KM hiding (map)
import Data.HashSet qualified as HashSet
import Data.List qualified as List import Data.List qualified as List
import Data.Text (unpack, splitOn, replace) import Data.Text (unpack, splitOn, replace)
import Data.Time (defaultTimeLocale, iso8601DateFormat, parseTimeM, toGregorian) import Data.Time (defaultTimeLocale, iso8601DateFormat, parseTimeM, toGregorian)
import Data.Time.Calendar qualified as DTC import Data.Time.Calendar qualified as DTC
import Data.Time.Clock (UTCTime(..), secondsToDiffTime) -- , getCurrentTime) import Data.Time.Clock (UTCTime(..), secondsToDiffTime)
import Data.Time.LocalTime (utc)
import Data.Time.LocalTime.TimeZone.Series (zonedTimeToZoneSeriesTime)
import Duckling.Api (analyze)
import Duckling.Core (makeLocale, Dimension(Time))
import Duckling.Core qualified as DC
import Duckling.Resolve (fromUTC, Context(Context, referenceTime, locale), DucklingTime(DucklingTime), Options(..))
import Duckling.Types (ResolvedToken(..), ResolvedVal(..), Seal(..))
import Gargantext.Core (Lang(FR,EN))
-- import Gargantext.Core.Types (DebugMode(..), withDebugMode)
import Gargantext.Prelude hiding (replace) import Gargantext.Prelude hiding (replace)
import System.Environment (getEnv)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Parse date to Ints -- | Parse date to Ints
-- TODO add hours, minutes and seconds -- TODO add hours, minutes and seconds
...@@ -89,13 +80,6 @@ parse s = do ...@@ -89,13 +80,6 @@ parse s = do
-- $ getCurrentTime) -- $ getCurrentTime)
_ -> Left "[G.C.T.C.Parsers.Date] parse: Should not happen" _ -> Left "[G.C.T.C.Parsers.Date] parse: Should not happen"
defaultDate :: Text
defaultDate = "0-0-0T0:0:0"
type DateFormat = Text
type DateDefault = Text
data DateFlow = DucklingSuccess { ds_result :: Text } data DateFlow = DucklingSuccess { ds_result :: Text }
| DucklingFailure { df_result :: Text } | DucklingFailure { df_result :: Text }
| ReadFailure1 { rf1_result :: Text } | ReadFailure1 { rf1_result :: Text }
...@@ -131,83 +115,9 @@ readDate txt = do ...@@ -131,83 +115,9 @@ readDate txt = do
parseTimeM True defaultTimeLocale (unpack format) (cs txt) parseTimeM True defaultTimeLocale (unpack format) (cs txt)
-- TODO add Paris at Duckling.Locale Region datatype
-- | To get Homogeinity of the languages
-- TODO : put this in a more generic place in the source code
parserLang :: Lang -> DC.Lang
parserLang FR = DC.FR
parserLang EN = DC.EN
parserLang lang = panic $ "[G.C.T.C.P.Date] Lang not implemented" <> (show lang)
-- | Final Date parser API
-- IO can be avoided here:
-- currentContext :: Lang -> IO Context
-- currentContext lang = localContext lang <$> utcToDucklingTime <$> getCurrentTime
-- parseRaw :: Context -> Text -> SomeErrorHandling Text
parseRawSafe :: Lang -> Text -> IO DateFlow
parseRawSafe lang text = do
let triedParseRaw = parseRaw lang text
dateStr' <- case triedParseRaw of
--Left (CE.SomeException err) -> do
Left _err -> do
_envLang <- getEnv "LANG"
-- printDebug "[G.C.T.C.P.Date] Exception: " (err, envLang, lang, text)
pure $ DucklingFailure text
Right res -> pure $ DucklingSuccess res
pure dateStr'
--tryParseRaw :: CE.Exception e => Lang -> Text -> IO (Either e Text)
--tryParseRaw lang text = CE.try (parseRaw lang text)
parseRaw :: Lang -> Text -> Either Text Text
parseRaw lang text = do -- case result
let maybeResult = extractValue $ getTimeValue
$ parseDateWithDuckling lang text (Options True)
case maybeResult of
Just result -> Right result
Nothing -> do
-- printDebug ("[G.C.T.C.P.D.parseRaw] ERROR " <> (cs . show) lang) text
Left $ "[G.C.T.C.P.D.parseRaw ERROR] " <> show lang <> " :: " <> text
getTimeValue :: [ResolvedToken] -> Maybe Value
getTimeValue rt = case head rt of
Nothing -> do
Nothing
Just x -> case rval x of
RVal Time t -> Just $ toJSON t
_ -> do
Nothing
extractValue :: Maybe Value -> Maybe Text
extractValue (Just (Json.Object object)) =
case KM.lookup "value" object of
Just (Json.String date) -> Just date
_ -> Nothing
extractValue _ = Nothing
-- | Current Time in DucklingTime format
-- TODO : get local Time in a more generic way
utcToDucklingTime :: UTCTime -> DucklingTime
utcToDucklingTime time = DucklingTime . zonedTimeToZoneSeriesTime $ fromUTC time utc
-- | Local Context which depends on Lang and Time
localContext :: Lang -> DucklingTime -> Context
localContext lang dt = Context { referenceTime = dt
, locale = makeLocale (parserLang lang) Nothing }
defaultDay :: DTC.Day defaultDay :: DTC.Day
defaultDay = DTC.fromGregorian 1 1 1 defaultDay = DTC.fromGregorian 1 1 1
defaultUTCTime :: UTCTime defaultUTCTime :: UTCTime
defaultUTCTime = UTCTime { utctDay = defaultDay defaultUTCTime = UTCTime { utctDay = defaultDay
, utctDayTime = secondsToDiffTime 0 } , utctDayTime = secondsToDiffTime 0 }
-- | Date parser with Duckling
parseDateWithDuckling :: Lang -> Text -> Options -> [ResolvedToken]
parseDateWithDuckling lang input options = do
let contxt = localContext lang $ utcToDucklingTime defaultUTCTime
--pure $ parseAndResolve (rulesFor (locale ctx) (HashSet.fromList [(This Time)])) input ctx
-- TODO check/test Options False or True
analyze input contxt options $ HashSet.fromList [(Seal Time)]
...@@ -54,6 +54,7 @@ import Gargantext.Database.Schema.Node ( NodePolySearch(_ns_hyperdata, _ns_searc ...@@ -54,6 +54,7 @@ import Gargantext.Database.Schema.Node ( NodePolySearch(_ns_hyperdata, _ns_searc
import Gargantext.Prelude hiding (groupBy) import Gargantext.Prelude hiding (groupBy)
import Opaleye hiding (Order) import Opaleye hiding (Order)
import Opaleye qualified as O hiding (Order) import Opaleye qualified as O hiding (Order)
import Opaleye.TextSearch
-- --
-- Interpreting a query into a Postgres' TSQuery -- Interpreting a query into a Postgres' TSQuery
......
...@@ -11,12 +11,13 @@ Portability : POSIX ...@@ -11,12 +11,13 @@ Portability : POSIX
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia #-} {-# LANGUAGE DerivingVia #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
-- {-# LANGUAGE DuplicateRecordFields #-} -- {-# LANGUAGE DuplicateRecordFields #-}
...@@ -24,12 +25,13 @@ module Gargantext.Database.Admin.Types.Node ...@@ -24,12 +25,13 @@ module Gargantext.Database.Admin.Types.Node
where where
import Codec.Serialise (Serialise()) import Codec.Serialise (Serialise())
import Data.Aeson (FromJSONKey, ToJSONKey) import Data.Aeson as JSON
import Data.Aeson.Types
import Data.Csv qualified as Csv import Data.Csv qualified as Csv
import Data.Morpheus.Kind (SCALAR) import Data.Morpheus.Kind (SCALAR)
import Data.Morpheus.Types ( DecodeScalar(..), EncodeScalar(..), GQLType(KIND) ) import Data.Morpheus.Types ( DecodeScalar(..), EncodeScalar(..), GQLType(KIND) )
import Data.Swagger import Data.Swagger
import Data.Text (unpack, pack) import Data.Text (pack, unpack)
import Data.Time (UTCTime) import Data.Time (UTCTime)
import Data.TreeDiff import Data.TreeDiff
import Database.PostgreSQL.Simple.FromField (FromField, fromField, fromJSONField) import Database.PostgreSQL.Simple.FromField (FromField, fromField, fromJSONField)
...@@ -41,12 +43,13 @@ import Gargantext.Database.Schema.Context ...@@ -41,12 +43,13 @@ import Gargantext.Database.Schema.Context
import Gargantext.Database.Schema.Node ( NodePoly(Node), NodePolySearch(NodeSearch) ) import Gargantext.Database.Schema.Node ( NodePoly(Node), NodePolySearch(NodeSearch) )
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Prelude.Crypto.Hash (Hash) import Gargantext.Prelude.Crypto.Hash (Hash)
import Opaleye (DefaultFromField, defaultFromField, SqlInt4, SqlText, SqlTSVector, Nullable, fromPGSFromField) import Opaleye (DefaultFromField, defaultFromField, SqlInt4, SqlText, Nullable, fromPGSFromField)
import Opaleye.TextSearch (SqlTSVector)
import Opaleye qualified as O import Opaleye qualified as O
import Prelude qualified import Prelude qualified
import Servant hiding (Context) import Servant hiding (Context)
import Test.QuickCheck (elements, Positive (getPositive)) import Test.QuickCheck (elements, Positive (getPositive))
import Test.QuickCheck.Arbitrary ( Arbitrary(arbitrary) ) import Test.QuickCheck.Arbitrary ( Arbitrary(arbitrary), arbitraryBoundedEnum)
import Test.QuickCheck.Instances.Text () import Test.QuickCheck.Instances.Text ()
import Test.QuickCheck.Instances.Time () import Test.QuickCheck.Instances.Time ()
import Text.Read (read) import Text.Read (read)
...@@ -405,37 +408,142 @@ instance ToSchema Resource where ...@@ -405,37 +408,142 @@ instance ToSchema Resource where
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Then a Node can be either a Folder or a Corpus or a Document -- | Then a Node can be either a Folder or a Corpus or a Document
data NodeType = NodeUser data NodeType
| NodeFolderPrivate = NodeUser
| NodeFolderShared | NodeTeam | NodeFolderPrivate
| NodeFolderPublic | NodeFolderShared
| NodeFolder | NodeTeam
| NodeFolderPublic
-- | NodeAnalysis | NodeCommunity | NodeFolder
| NodeCorpus
| NodeCorpus | NodeCorpusV3 | NodeTexts | NodeDocument | NodeCorpusV3
| NodeAnnuaire | NodeContact | NodeTexts
| NodeGraph | NodePhylo | NodeDocument
| NodeDashboard -- | NodeChart | NodeNoteBook | NodeAnnuaire
| NodeList | NodeModel | NodeContact
| NodeListCooc | NodeGraph
| NodePhylo
{- | NodeDashboard
-- | Metrics | NodeList
-- | NodeOccurrences | NodeModel
-- | Classification | NodeListCooc
-} -- Optional Nodes
| Notes
-- Optional Nodes | Calc
| Notes | Calc | NodeFrameVisio | NodeFrameNotebook | NodeFrameVisio
| NodeFile | NodeFrameNotebook
| NodeFile
deriving (Show, Read, Eq, Ord, Generic, Bounded, Enum) deriving (Show, Read, Eq, Ord, Generic, Bounded, Enum)
instance GQLType NodeType instance GQLType NodeType
instance FromJSON NodeType
instance ToJSON NodeType -- /NOTE/ (adn) For backward-compatibility reasons, we keep the format for ToJSON/FromJSON similar
-- to what 'Show/Read' would generate, but we otherwise generate \"by hand\" the mapping between a
-- NodeType and its JSON representation, because this way we reduce the odds of /breaking the frontend/
-- in case we change the Show/Read instances in the future.
instance ToJSON NodeType where
toJSON = JSON.String . \case
NodeUser
-> "NodeUser"
NodeFolderPrivate
-> "NodeFolderPrivate"
NodeFolderShared
-> "NodeFolderShared"
NodeTeam
-> "NodeTeam"
NodeFolderPublic
-> "NodeFolderPublic"
NodeFolder
-> "NodeFolder"
NodeCorpus
-> "NodeCorpus"
NodeCorpusV3
-> "NodeCorpusV3"
NodeTexts
-> "NodeTexts"
NodeDocument
-> "NodeDocument"
NodeAnnuaire
-> "NodeAnnuaire"
NodeContact
-> "NodeContact"
NodeGraph
-> "NodeGraph"
NodePhylo
-> "NodePhylo"
NodeDashboard
-> "NodeDashboard"
NodeList
-> "NodeList"
NodeModel
-> "NodeModel"
NodeListCooc
-> "NodeListCooc"
Notes
-> "Notes"
Calc
-> "Calc"
NodeFrameVisio
-> "NodeFrameVisio"
NodeFrameNotebook
-> "NodeFrameNotebook"
NodeFile
-> "NodeFile"
instance FromJSON NodeType where
parseJSON = withText "NodeType" $ \t -> case t of
"NodeUser"
-> pure NodeUser
"NodeFolderPrivate"
-> pure NodeFolderPrivate
"NodeFolderShared"
-> pure NodeFolderShared
"NodeTeam"
-> pure NodeTeam
"NodeFolderPublic"
-> pure NodeFolderPublic
"NodeFolder"
-> pure NodeFolder
"NodeCorpus"
-> pure NodeCorpus
"NodeCorpusV3"
-> pure NodeCorpusV3
"NodeTexts"
-> pure NodeTexts
"NodeDocument"
-> pure NodeDocument
"NodeAnnuaire"
-> pure NodeAnnuaire
"NodeContact"
-> pure NodeContact
"NodeGraph"
-> pure NodeGraph
"NodePhylo"
-> pure NodePhylo
"NodeDashboard"
-> pure NodeDashboard
"NodeList"
-> pure NodeList
"NodeModel"
-> pure NodeModel
"NodeListCooc"
-> pure NodeListCooc
"Notes"
-> pure Notes
"Calc"
-> pure Calc
"NodeFrameVisio"
-> pure NodeFrameVisio
"NodeFrameNotebook"
-> pure NodeFrameNotebook
"NodeFile"
-> pure NodeFile
unhandled
-> typeMismatch "NodeType" (JSON.String unhandled)
-- | FIXME(adn) these instances could reuse the fromJSON/toJSON instances,
-- but for some reason this broke the frontend:
-- https://gitlab.iscpif.fr/gargantext/haskell-gargantext/merge_requests/277#note_10388
instance FromHttpApiData NodeType where instance FromHttpApiData NodeType where
parseUrlPiece = Right . read . unpack parseUrlPiece = Right . read . unpack
instance ToHttpApiData NodeType where instance ToHttpApiData NodeType where
...@@ -443,7 +551,7 @@ instance ToHttpApiData NodeType where ...@@ -443,7 +551,7 @@ instance ToHttpApiData NodeType where
instance ToParamSchema NodeType instance ToParamSchema NodeType
instance ToSchema NodeType instance ToSchema NodeType
instance Arbitrary NodeType where instance Arbitrary NodeType where
arbitrary = elements allNodeTypes arbitrary = arbitraryBoundedEnum
instance FromField NodeType where instance FromField NodeType where
fromField = fromJSONField fromField = fromJSONField
instance ToField NodeType where instance ToField NodeType where
......
...@@ -27,6 +27,7 @@ module Gargantext.Database.Schema.Prelude ...@@ -27,6 +27,7 @@ module Gargantext.Database.Schema.Prelude
, module Opaleye , module Opaleye
, module Opaleye.Internal.Table , module Opaleye.Internal.Table
, module Opaleye.Internal.QueryArr , module Opaleye.Internal.QueryArr
, module Opaleye.TextSearch
, module Test.QuickCheck.Arbitrary , module Test.QuickCheck.Arbitrary
) )
where where
...@@ -41,6 +42,7 @@ import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger) ...@@ -41,6 +42,7 @@ import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
import Opaleye hiding (FromField) import Opaleye hiding (FromField)
import Opaleye.Internal.QueryArr (Query) import Opaleye.Internal.QueryArr (Query)
import Opaleye.Internal.Table (Table(..)) import Opaleye.Internal.Table (Table(..))
import Opaleye.TextSearch
import Test.QuickCheck.Arbitrary hiding (vector) import Test.QuickCheck.Arbitrary hiding (vector)
import Database.PostgreSQL.Simple.FromField (FromField, fromField) import Database.PostgreSQL.Simple.FromField (FromField, fromField)
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
- "KMP-0.2.0.0" - "KMP-0.2.0.0"
- "MissingH-1.4.3.0" - "MissingH-1.4.3.0"
- "Unique-0.4.7.8" - "Unique-0.4.7.8"
- "dependent-sum-0.7.1.0"
- "fclabels-2.0.5.1" - "fclabels-2.0.5.1"
- "full-text-search-0.2.1.4" - "full-text-search-0.2.1.4"
- "fullstop-0.1.4" - "fullstop-0.1.4"
...@@ -28,6 +27,7 @@ ...@@ -28,6 +27,7 @@
- "morpheus-graphql-server-0.24.3" - "morpheus-graphql-server-0.24.3"
- "morpheus-graphql-subscriptions-0.24.3" - "morpheus-graphql-subscriptions-0.24.3"
- "morpheus-graphql-tests-0.24.3" - "morpheus-graphql-tests-0.24.3"
- "opaleye-0.9.6.1"
- "rake-0.0.1" - "rake-0.0.1"
- "random-1.2.1" - "random-1.2.1"
- "recover-rtti-0.4.3" - "recover-rtti-0.4.3"
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
- "servant-ekg-0.3.1" - "servant-ekg-0.3.1"
- "servant-flatten-0.2" - "servant-flatten-0.2"
- "servant-server-0.20" - "servant-server-0.20"
- "snap-server-1.1.2.1"
- "stemmer-0.5.2" - "stemmer-0.5.2"
- "taggy-0.2.1" - "taggy-0.2.1"
- "taggy-lens-0.1.2" - "taggy-lens-0.1.2"
...@@ -62,10 +61,6 @@ ...@@ -62,10 +61,6 @@
git: "https://github.com/MercuryTechnologies/ekg-json.git" git: "https://github.com/MercuryTechnologies/ekg-json.git"
subdirs: subdirs:
- . - .
- commit: 23603a832117e5352d5b0fb9bb1110228324b35a
git: "https://github.com/adinapoli/duckling.git"
subdirs:
- .
- commit: 7533a9ccd3bfe77141745f6b61039a26aaf5c83b - commit: 7533a9ccd3bfe77141745f6b61039a26aaf5c83b
git: "https://github.com/adinapoli/llvm-hs.git" git: "https://github.com/adinapoli/llvm-hs.git"
subdirs: subdirs:
...@@ -74,10 +69,6 @@ ...@@ -74,10 +69,6 @@
git: "https://github.com/adinapoli/llvm-hs.git" git: "https://github.com/adinapoli/llvm-hs.git"
subdirs: subdirs:
- "llvm-hs-pure" - "llvm-hs-pure"
- commit: 85533b5d597e6fc5498411b4bcfc76380ec80d71
git: "https://github.com/adinapoli/text16-compat.git"
subdirs:
- .
- commit: a110807651036ca2228a76507ee35bbf7aedf87a - commit: a110807651036ca2228a76507ee35bbf7aedf87a
git: "https://github.com/alpmestan/accelerate-arithmetic.git" git: "https://github.com/alpmestan/accelerate-arithmetic.git"
subdirs: subdirs:
...@@ -110,10 +101,6 @@ ...@@ -110,10 +101,6 @@
git: "https://github.com/delanoe/patches-map" git: "https://github.com/delanoe/patches-map"
subdirs: subdirs:
- . - .
- commit: 6cf1bcfe215143efac17919cfd0abdd60e0f717c
git: "https://github.com/garganscript/haskell-opaleye.git"
subdirs:
- .
- commit: 4fd2edf30c141600ffad6d730cc4c1c08a6dbce4 - commit: 4fd2edf30c141600ffad6d730cc4c1c08a6dbce4
git: "https://github.com/robstewart57/rdf4h.git" git: "https://github.com/robstewart57/rdf4h.git"
subdirs: subdirs:
...@@ -174,6 +161,10 @@ ...@@ -174,6 +161,10 @@
git: "https://gitlab.iscpif.fr/gargantext/iso639.git" git: "https://gitlab.iscpif.fr/gargantext/iso639.git"
subdirs: subdirs:
- . - .
- commit: cb07b604bfb7a22aa21dd8918de5cb65c8a4bdf1
git: "https://gitlab.iscpif.fr/gargantext/opaleye-textsearch.git"
subdirs:
- .
- commit: 3668d28607867a88b2dfc62158139b3cfd629ddb - commit: 3668d28607867a88b2dfc62158139b3cfd629ddb
git: "https://gitlab.iscpif.fr/gargantext/patches-class.git" git: "https://gitlab.iscpif.fr/gargantext/patches-class.git"
subdirs: subdirs:
...@@ -260,8 +251,6 @@ flags: ...@@ -260,8 +251,6 @@ flags:
containers: true containers: true
distributive: true distributive: true
"indexed-traversable": true "indexed-traversable": true
"constraints-extras":
"build-readme": true
contravariant: contravariant:
semigroups: true semigroups: true
statevar: true statevar: true
...@@ -321,8 +310,6 @@ flags: ...@@ -321,8 +310,6 @@ flags:
"disable-db-obfuscation-executable": false "disable-db-obfuscation-executable": false
"no-phylo-debug-logs": true "no-phylo-debug-logs": true
"test-crypto": false "test-crypto": false
"generic-deriving":
"base-4-9": true
"ghc-lib-parser": "ghc-lib-parser":
"threaded-rts": true "threaded-rts": true
"ghc-lib-parser-ex": "ghc-lib-parser-ex":
...@@ -378,10 +365,6 @@ flags: ...@@ -378,10 +365,6 @@ flags:
"integer-logarithms": "integer-logarithms":
"check-bounds": false "check-bounds": false
"integer-gmp": true "integer-gmp": true
"io-streams":
network: true
nointeractivetests: false
zlib: true
"ipython-kernel": "ipython-kernel":
examples: false examples: false
jose: jose:
...@@ -471,8 +454,6 @@ flags: ...@@ -471,8 +454,6 @@ flags:
reflection: reflection:
slow: false slow: false
"template-haskell": true "template-haskell": true
"regex-pcre":
"pkg-config": true
"regex-posix": "regex-posix":
"_regex-posix-clib": false "_regex-posix-clib": false
"regex-tdfa": "regex-tdfa":
...@@ -518,16 +499,6 @@ flags: ...@@ -518,16 +499,6 @@ flags:
executable: false executable: false
"skylighting-core": "skylighting-core":
executable: false executable: false
"snap-core":
debug: false
"network-uri": true
portable: false
"snap-server":
"build-pong": false
"build-testserver": false
debug: false
openssl: false
portable: false
some: some:
"newtype-unsafe": true "newtype-unsafe": true
splitmix: splitmix:
...@@ -553,13 +524,6 @@ flags: ...@@ -553,13 +524,6 @@ flags:
dev: false dev: false
"text-short": "text-short":
asserts: false asserts: false
"text-show":
"base-4-9": true
"integer-gmp": true
"new-functor-classes": true
"template-haskell-2-11": true
"text16-compat":
"enable-golden-test-generation": false
"time-compat": "time-compat":
"old-locale": false "old-locale": false
"time-locale-compat": "time-locale-compat":
......
#!/bin/bash #!/bin/bash
FOLDER="logs"
FILE=$(date +%Y%m%d%H%M.log)
LOGFILE=$FOLDER"/"$FILE
mkdir -p $FOLDER
echo "GarganText: Starting project..." echo "GarganText: Starting project..."
echo "GarganText: First, compiling code..." echo "GarganText: First, compiling code..."
bin/install bin/install
...@@ -10,7 +16,7 @@ docker compose up -d ...@@ -10,7 +16,7 @@ docker compose up -d
echo "GarganText: docker for postgresql database [OK]" echo "GarganText: docker for postgresql database [OK]"
cd ../../ cd ../../
echo "GarganText: gargantext-server with Nix and Cabal..." echo "GarganText: gargantext-server with Nix and Cabal..."
nix-shell --run "cabal run gargantext-server -- --ini gargantext.ini --run Prod" nix-shell --run "cabal run gargantext-server -- --ini gargantext.ini --run Prod +RTS > $LOGFILE 2>&1 & tail -F $LOGFILE"
echo "GarganText: gargantext-server with Nix and Cabal [OK]" echo "GarganText: gargantext-server with Nix and Cabal [OK]"
echo "GarganText: project stopped." echo "GarganText: project stopped."
...@@ -19,10 +19,9 @@ import Text.RawString.QQ (r) ...@@ -19,10 +19,9 @@ import Text.RawString.QQ (r)
tests :: Spec tests :: Spec
tests = sequential $ aroundAll withTestDBAndPort $ do tests = sequential $ aroundAll withTestDBAndPort $ do
describe "Prelude" $ do
it "setup DB triggers" $ \((testEnv, _), _) -> setupEnvironment testEnv
describe "GraphQL" $ do describe "GraphQL" $ do
describe "Prelude" $ do
it "setup DB triggers" $ \((testEnv, _), _) -> setupEnvironment testEnv
describe "get_user_infos" $ do describe "get_user_infos" $ do
it "allows 'alice' to see her own info" $ \((testEnv, port), app) -> do it "allows 'alice' to see her own info" $ \((testEnv, port), app) -> do
...@@ -34,6 +33,13 @@ tests = sequential $ aroundAll withTestDBAndPort $ do ...@@ -34,6 +33,13 @@ tests = sequential $ aroundAll withTestDBAndPort $ do
let expected = [json| {"data":{"user_infos":[{"ui_id":2,"ui_email":"alice@gargan.text"}]}} |] let expected = [json| {"data":{"user_infos":[{"ui_id":2,"ui_email":"alice@gargan.text"}]}} |]
protected token "POST" "/gql" query `shouldRespondWithFragment` expected protected token "POST" "/gql" query `shouldRespondWithFragment` expected
describe "nodes" $ do
it "returns node_type" $ \((_testEnv, port), app) -> do
withApplication app $ do
withValidLogin port "gargantua" (GargPassword "secret_key") $ \token -> do
let query = [r| { "query": "{ nodes(node_id: 2) { node_type } }" } |]
let expected = [json| {"data":{"nodes":[{"node_type":"NodeFolderPrivate"}]}} |]
protected token "POST" "/gql" query `shouldRespondWithFragment` expected
describe "check error format" $ do describe "check error format" $ do
it "returns the new error if header X-Garg-Error-Scheme: new is passed" $ \((_testEnv, port), app) -> do it "returns the new error if header X-Garg-Error-Scheme: new is passed" $ \((_testEnv, port), app) -> do
......
...@@ -30,6 +30,7 @@ jsonRoundtrip a = ...@@ -30,6 +30,7 @@ jsonRoundtrip a =
class (Show a, FromJSON a, ToJSON a, Eq a, Enum a, Bounded a) => EnumBoundedJSON a class (Show a, FromJSON a, ToJSON a, Eq a, Enum a, Bounded a) => EnumBoundedJSON a
instance EnumBoundedJSON BackendErrorCode instance EnumBoundedJSON BackendErrorCode
instance EnumBoundedJSON NodeType
jsonEnumRoundtrip :: forall a. Dict EnumBoundedJSON a -> Property jsonEnumRoundtrip :: forall a. Dict EnumBoundedJSON a -> Property
jsonEnumRoundtrip d = case d of jsonEnumRoundtrip d = case d of
...@@ -54,6 +55,7 @@ tests = testGroup "JSON" [ ...@@ -54,6 +55,7 @@ tests = testGroup "JSON" [
, testProperty "WithQuery roundtrips" (jsonRoundtrip @WithQuery) , testProperty "WithQuery roundtrips" (jsonRoundtrip @WithQuery)
, testProperty "FrontendError roundtrips" jsonFrontendErrorRoundtrip , testProperty "FrontendError roundtrips" jsonFrontendErrorRoundtrip
, testProperty "BackendErrorCode roundtrips" (jsonEnumRoundtrip (Dict @_ @BackendErrorCode)) , testProperty "BackendErrorCode roundtrips" (jsonEnumRoundtrip (Dict @_ @BackendErrorCode))
, testProperty "NodeType roundtrips" (jsonEnumRoundtrip (Dict @_ @NodeType))
, testCase "WithQuery frontend compliance" testWithQueryFrontend , testCase "WithQuery frontend compliance" testWithQueryFrontend
, testGroup "Phylo" [ , testGroup "Phylo" [
testProperty "PeriodToNode" (jsonRoundtrip @PeriodToNodeData) testProperty "PeriodToNode" (jsonRoundtrip @PeriodToNodeData)
......
...@@ -16,39 +16,16 @@ module Test.Parsers.Date where ...@@ -16,39 +16,16 @@ module Test.Parsers.Date where
import Test.Hspec import Test.Hspec
import Test.QuickCheck
import Data.Time (ZonedTime(..))
import Data.Time.Clock (UTCTime(..), secondsToDiffTime) import Data.Time.Clock (UTCTime(..), secondsToDiffTime)
import Data.Time.Calendar.OrdinalDate (fromOrdinalDate) import Data.Time.Calendar.OrdinalDate (fromOrdinalDate)
import Data.Text (pack)
import Text.Parsec.Error (ParseError)
import Duckling.Time.Types (toRFC3339)
----------------------------------------------------------- -----------------------------------------------------------
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Core.Text.Corpus.Parsers.Date (dateSplit) import Gargantext.Core.Text.Corpus.Parsers.Date (dateSplit)
import Gargantext.Core.Text.Corpus.Parsers.Date.Parsec (fromRFC3339)
import Test.Parsers.Types
----------------------------------------------------------- -----------------------------------------------------------
fromRFC3339Inv :: Either ParseError ZonedTime -> Text
fromRFC3339Inv (Right z) = toRFC3339 z
fromRFC3339Inv (Left pe) = panic . pack $ show pe
testFromRFC3339 :: Spec
testFromRFC3339 = do
describe "Test fromRFC3339: " $ do
it "is the inverse of Duckling's toRFC3339" $ property $
((==) <*> (fromRFC3339 . fromRFC3339Inv)) . Right . looseZonedTimePrecision
-- \x -> uncurry (==) $ (,) <*> (fromRFC3339 . fromRFC3339Inv) $ Right $ looseZonedTimePrecision x
-- \x -> let e = Right x :: Either ParseError ZonedTime
-- in fmap looseZonedTimePrecision e == (fromRFC3339 . fromRFC3339Inv ) (fmap looseZonedTimePrecision e)
testDateSplit :: Spec testDateSplit :: Spec
testDateSplit = do testDateSplit = do
describe "Test date split" $ do describe "Test date split" $ do
......
...@@ -33,7 +33,6 @@ main :: IO () ...@@ -33,7 +33,6 @@ main :: IO ()
main = do main = do
utilSpec <- testSpec "Utils" Utils.test utilSpec <- testSpec "Utils" Utils.test
clusteringSpec <- testSpec "Graph Clustering" Graph.test clusteringSpec <- testSpec "Graph Clustering" Graph.test
dateParserSpec <- testSpec "Date Parsing" PD.testFromRFC3339
dateSplitSpec <- testSpec "Date split" PD.testDateSplit dateSplitSpec <- testSpec "Date split" PD.testDateSplit
cryptoSpec <- testSpec "Crypto" Crypto.test cryptoSpec <- testSpec "Crypto" Crypto.test
nlpSpec <- testSpec "NLP" NLP.test nlpSpec <- testSpec "NLP" NLP.test
...@@ -43,7 +42,6 @@ main = do ...@@ -43,7 +42,6 @@ main = do
defaultMain $ testGroup "Gargantext" defaultMain $ testGroup "Gargantext"
[ utilSpec [ utilSpec
, clusteringSpec , clusteringSpec
, dateParserSpec
, dateSplitSpec , dateSplitSpec
, cryptoSpec , cryptoSpec
, nlpSpec , nlpSpec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment