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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Christian Merten
haskell-gargantext
Commits
d5837c97
Commit
d5837c97
authored
Dec 16, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[refactoring] add Gargantext.Defaults and default year/month/day
parent
43efa783
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
48 additions
and
17 deletions
+48
-17
package.yaml
package.yaml
+1
-0
DocumentsFromWriteNodes.hs
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
+4
-3
Search.hs
src/Gargantext/API/Search.hs
+7
-6
Hal.hs
src/Gargantext/Core/Text/Corpus/API/Hal.hs
+2
-1
Isidore.hs
src/Gargantext/Core/Text/Corpus/API/Isidore.hs
+2
-1
Istex.hs
src/Gargantext/Core/Text/Corpus/API/Istex.hs
+2
-1
Json2Csv.hs
src/Gargantext/Core/Text/Corpus/Parsers/Json2Csv.hs
+3
-2
Insert.hs
src/Gargantext/Database/Query/Table/Node/Document/Insert.hs
+4
-3
Defaults.hs
src/Gargantext/Defaults.hs
+23
-0
No files found.
package.yaml
View file @
d5837c97
...
...
@@ -78,6 +78,7 @@ library:
-
Gargantext.Database.Admin.Config
-
Gargantext.Database.Admin.Types.Hyperdata
-
Gargantext.Database.Admin.Types.Node
-
Gargantext.Defaults
-
Gargantext.Core.Text
-
Gargantext.Core.Text.Context
-
Gargantext.Core.Text.Corpus.Parsers
...
...
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
View file @
d5837c97
...
...
@@ -36,6 +36,7 @@ import Gargantext.Database.Admin.Types.Hyperdata.Frame
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Query.Table.Node
(
getChildrenByType
,
getClosestParentIdByType'
,
getNodeWith
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
qualified
Gargantext.Defaults
as
Defaults
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
Servant
...
...
@@ -114,9 +115,9 @@ hyperdataDocumentFromFrameWrite (HyperdataFrame { _hf_base, _hf_frame_id }, cont
date'
=
(
\
(
Date
{
year
,
month
,
day
})
->
T
.
concat
[
T
.
pack
$
show
year
,
"-"
,
T
.
pack
$
show
month
,
"-"
,
T
.
pack
$
show
day
])
<$>
date
year'
=
fromIntegral
$
maybe
2021
(
\
(
Date
{
year
})
->
year
)
date
month'
=
fromIntegral
$
maybe
10
(
\
(
Date
{
month
})
->
month
)
date
day'
=
fromIntegral
$
maybe
4
(
\
(
Date
{
day
})
->
day
)
date
in
year'
=
fromIntegral
$
maybe
Defaults
.
year
(
\
(
Date
{
year
})
->
year
)
date
month'
=
maybe
Defaults
.
month
(
\
(
Date
{
month
})
->
fromIntegral
month
)
date
day'
=
maybe
Defaults
.
day
(
\
(
Date
{
day
})
->
fromIntegral
day
)
date
in
Right
HyperdataDocument
{
_hd_bdd
=
Just
"FrameWrite"
,
_hd_doi
=
Nothing
,
_hd_url
=
Nothing
...
...
src/Gargantext/API/Search.hs
View file @
d5837c97
...
...
@@ -31,6 +31,7 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataContact(..), Hyperdat
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
_cw_organization
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Query.Facet
import
qualified
Gargantext.Defaults
as
Defaults
import
Gargantext.Prelude
import
Gargantext.Utils.Aeson
(
defaultTaggedObject
)
import
Servant
...
...
@@ -258,12 +259,12 @@ instance ToHyperdataRow HyperdataDocument where
,
_hr_language_iso2
=
fromMaybe
"EN"
_hd_language_iso2
,
_hr_page
=
fromMaybe
0
_hd_page
,
_hr_publication_date
=
fromMaybe
""
_hd_publication_date
,
_hr_publication_
day
=
fromMaybe
1
_hd_publication_day
,
_hr_publication_
hour
=
fromMaybe
1
_hd_publication_hour
,
_hr_publication_
minute
=
fromMaybe
1
_hd_publication_minute
,
_hr_publication_
month
=
fromMaybe
1
_hd_publication_month
,
_hr_publication_
second
=
fromMaybe
1
_hd_publication_second
,
_hr_publication_
year
=
fromMaybe
2020
_hd_publication_year
,
_hr_publication_
year
=
fromMaybe
(
fromIntegral
Defaults
.
year
)
_hd_publication_year
,
_hr_publication_
month
=
fromMaybe
Defaults
.
month
_hd_publication_month
,
_hr_publication_
day
=
fromMaybe
Defaults
.
day
_hd_publication_day
,
_hr_publication_
hour
=
fromMaybe
0
_hd_publication_hour
,
_hr_publication_
minute
=
fromMaybe
0
_hd_publication_minute
,
_hr_publication_
second
=
fromMaybe
0
_hd_publication_second
,
_hr_source
=
fromMaybe
""
_hd_source
,
_hr_title
=
fromMaybe
"Title"
_hd_title
,
_hr_url
=
fromMaybe
""
_hd_url
...
...
src/Gargantext/Core/Text/Corpus/API/Hal.hs
View file @
d5837c97
...
...
@@ -17,6 +17,7 @@ import Data.Text (Text, pack, intercalate)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
qualified
Gargantext.Defaults
as
Defaults
import
Gargantext.Prelude
import
qualified
Gargantext.Core.Text.Corpus.Parsers.Date
as
Date
import
qualified
HAL
as
HAL
...
...
@@ -30,7 +31,7 @@ get la q ml = do
toDoc'
::
Lang
->
HAL
.
Corpus
->
IO
HyperdataDocument
toDoc'
la
(
HAL
.
Corpus
i
t
ab
d
s
aus
affs
struct_id
)
=
do
(
utctime
,
(
pub_year
,
pub_month
,
pub_day
))
<-
Date
.
dateSplit
la
(
maybe
(
Just
"2019"
)
Just
d
)
(
utctime
,
(
pub_year
,
pub_month
,
pub_day
))
<-
Date
.
dateSplit
la
(
maybe
(
Just
$
pack
$
show
Defaults
.
year
)
Just
d
)
pure
$
HyperdataDocument
{
_hd_bdd
=
Just
"Hal"
,
_hd_doi
=
Just
$
pack
$
show
i
,
_hd_url
=
Nothing
...
...
src/Gargantext/Core/Text/Corpus/API/Isidore.hs
View file @
d5837c97
...
...
@@ -18,6 +18,7 @@ import Data.Text (Text)
import
qualified
Data.Text
as
Text
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
qualified
Gargantext.Defaults
as
Defaults
import
Gargantext.Prelude
import
Isidore.Client
import
Servant.Client
...
...
@@ -67,7 +68,7 @@ isidoreToDoc l (IsidoreDoc t a d u s as) = do
langText
(
OnlyText
t2
)
=
t2
langText
(
ArrayText
ts
)
=
Text
.
intercalate
" "
$
map
langText
ts
(
utcTime
,
(
pub_year
,
pub_month
,
pub_day
))
<-
Date
.
dateSplit
l
(
maybe
(
Just
"2019"
)
(
Just
)
d
)
(
utcTime
,
(
pub_year
,
pub_month
,
pub_day
))
<-
Date
.
dateSplit
l
(
maybe
(
Just
$
Text
.
pack
$
show
Defaults
.
year
)
(
Just
)
d
)
pure
$
HyperdataDocument
(
Just
"Isidore"
)
Nothing
...
...
src/Gargantext/Core/Text/Corpus/API/Istex.hs
View file @
d5837c97
...
...
@@ -19,6 +19,7 @@ import Data.Text (Text, pack)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
qualified
Gargantext.Defaults
as
Defaults
import
Gargantext.Prelude
import
qualified
Gargantext.Core.Text.Corpus.Parsers.Date
as
Date
import
qualified
ISTEX
as
ISTEX
...
...
@@ -38,7 +39,7 @@ toDoc' la docs' = do
-- TODO current year as default
toDoc
::
Lang
->
ISTEX
.
Document
->
IO
HyperdataDocument
toDoc
la
(
ISTEX
.
Document
i
t
a
ab
d
s
)
=
do
(
utctime
,
(
pub_year
,
pub_month
,
pub_day
))
<-
Date
.
dateSplit
la
(
maybe
(
Just
"2019"
)
(
Just
.
pack
.
show
)
d
)
(
utctime
,
(
pub_year
,
pub_month
,
pub_day
))
<-
Date
.
dateSplit
la
(
maybe
(
Just
$
pack
$
show
Defaults
.
year
)
(
Just
.
pack
.
show
)
d
)
pure
$
HyperdataDocument
{
_hd_bdd
=
Just
"Istex"
,
_hd_doi
=
Just
i
,
_hd_url
=
Nothing
...
...
src/Gargantext/Core/Text/Corpus/Parsers/Json2Csv.hs
View file @
d5837c97
...
...
@@ -23,6 +23,7 @@ import Data.Aeson.TH (deriveJSON)
import
Data.ByteString.Lazy
(
readFile
)
import
Data.Text
(
Text
,
unpack
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
qualified
Gargantext.Defaults
as
Defaults
import
Gargantext.Prelude
import
System.IO
(
FilePath
)
import
Gargantext.Core.Text.Corpus.Parsers.CSV
(
CsvDoc
(
..
),
writeFile
,
headerCsvGargV3
)
...
...
@@ -52,8 +53,8 @@ patent2csvDoc (Patent { .. }) =
CsvDoc
{
csv_title
=
_patent_title
,
csv_source
=
"Source"
,
csv_publication_year
=
Just
$
read
(
unpack
_patent_year
)
,
csv_publication_month
=
Just
1
,
csv_publication_day
=
Just
1
,
csv_publication_month
=
Just
$
Defaults
.
month
,
csv_publication_day
=
Just
$
Defaults
.
day
,
csv_abstract
=
_patent_abstract
,
csv_authors
=
"Authors"
}
...
...
src/Gargantext/Database/Query/Table/Node/Document/Insert.hs
View file @
d5837c97
...
...
@@ -74,6 +74,7 @@ import Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
Cmd
,
runPGSQuery
{-, formatPGSQuery-}
)
import
Gargantext.Database.Schema.Node
(
NodePoly
(
..
))
import
qualified
Gargantext.Defaults
as
Defaults
import
Gargantext.Prelude
import
Gargantext.Prelude.Crypto.Hash
(
hash
)
import
qualified
Data.Text
as
DT
(
pack
,
concat
,
take
)
...
...
@@ -282,9 +283,9 @@ instance ToNode HyperdataDocument where
-- NOTE: There is no year '0' in postgres, there is year 1 AD and beofre that year 1 BC:
-- select '0001-01-01'::date, '0001-01-01'::date - '1 day'::interval;
-- 0001-01-01 0001-12-31 00:00:00 BC
y
=
maybe
1
fromIntegral
$
_hd_publication_year
h
m
=
fromMaybe
1
$
_hd_publication_month
h
d
=
fromMaybe
1
$
_hd_publication_day
h
y
=
fromIntegral
$
fromMaybe
Defaults
.
day
$
_hd_publication_year
h
m
=
fromMaybe
Defaults
.
month
$
_hd_publication_month
h
d
=
fromMaybe
(
fromIntegral
Defaults
.
year
)
$
_hd_publication_day
h
-- TODO better Node
instance
ToNode
HyperdataContact
where
...
...
src/Gargantext/Defaults.hs
0 → 100644
View file @
d5837c97
{-|
Module : Gargantext.Defaults
Description : Gargantext default values
Copyright : (c) CNRS, 2021-present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
module
Gargantext.Defaults
where
import
Gargantext.Prelude
year
::
Integer
year
=
1
month
::
Int
month
=
1
day
::
Int
day
=
1
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