Commit 414815aa authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into dev-doc-table-cache-issue

parents 99fe38ff 0372a7ed
......@@ -4511,4 +4511,4 @@
"repo": "https://github.com/athanclark/purescript-zeta-extra.git",
"version": "v0.0.1"
}
}
}
\ No newline at end of file
{
"name": "Gargantext",
"version": "0.0.1.91.2",
"version": "0.0.1.91.3",
"scripts": {
"rebase-set": "spago package-set-upgrade && spago psc-package-insdhall",
"rebuild-set": "spago psc-package-insdhall",
......
let mkPackage =
https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.8-20200822/src/mkPackage.dhall sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57
--let upstream =
-- https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200822/packages.dhall sha256:2230fc547841b54bca815eb0058414aa03ed7b675042f8b3dda644e1952824e5
let upstream =
./packages-0.13.8-20200822.dhall
let overrides =
{ thermite =
mkPackage
[ "aff"
, "coroutines"
, "web-dom"
, "freet"
, "profunctor-lenses"
, "react"
, "react-dom"
]
"https://github.com/poorscript/purescript-thermite.git"
"hide-2020-03-04"
{ dependencies =
[ "aff"
, "coroutines"
, "web-dom"
, "freet"
, "profunctor-lenses"
, "react"
, "react-dom"
]
, repo = "https://github.com/poorscript/purescript-thermite.git"
, version = "hide-2020-03-04"
}
, globals =
mkPackage
[ "functions", "maybe" ]
"https://github.com/purescript/purescript-globals"
"v4.1.0"
{ dependencies = [ "functions", "maybe" ]
, repo = "https://github.com/purescript/purescript-globals"
, version = "v4.1.0"
}
}
let additions =
{ sequences =
mkPackage
{ dependencies =
[ "prelude"
, "unsafe-coerce"
, "partial"
......@@ -41,20 +36,23 @@ let additions =
, "tuples"
, "newtype"
]
"https://github.com/hdgarrood/purescript-sequences.git"
"v2.1.0"
, repo = "https://github.com/hdgarrood/purescript-sequences.git"
, version = "v2.1.0"
}
, spec-discovery =
mkPackage
{ dependencies =
[ "prelude", "effect", "arrays", "spec", "node-fs" ]
"https://github.com/purescript-spec/purescript-spec-discovery"
"v4.0.0"
, repo = "https://github.com/purescript-spec/purescript-spec-discovery"
, version = "v4.0.0"
}
, spec-quickcheck =
mkPackage
{ dependencies =
[ "prelude", "aff", "random", "quickcheck", "spec" ]
"https://github.com/purescript-spec/purescript-spec-quickcheck"
"v3.1.0"
, repo = "https://github.com/purescript-spec/purescript-spec-quickcheck"
, version = "v3.1.0"
}
, ffi-simple =
mkPackage
{ dependencies =
[ "prelude"
, "effect"
, "maybe"
......@@ -62,10 +60,11 @@ let additions =
, "nullable"
, "unsafe-coerce"
]
"https://github.com/irresponsible/purescript-ffi-simple"
"v0.2.10"
, repo = "https://github.com/irresponsible/purescript-ffi-simple"
, version = "v0.2.10"
}
, dom-simple =
mkPackage
{ dependencies =
[ "arrays"
, "console"
, "effect"
......@@ -75,30 +74,35 @@ let additions =
, "prelude"
, "unsafe-coerce"
]
"https://github.com/irresponsible/purescript-dom-simple"
"v0.2.7"
, repo = "https://github.com/irresponsible/purescript-dom-simple"
, version = "v0.2.7"
}
, dom-filereader =
mkPackage
{ dependencies =
[ "aff", "arraybuffer-types", "web-file", "web-html" ]
"https://github.com/nwolverson/purescript-dom-filereader"
"v5.0.0"
, repo = "https://github.com/nwolverson/purescript-dom-filereader"
, version = "v5.0.0"
}
, markdown =
mkPackage
{ dependencies =
[ "precise" ]
"https://github.com/poorscript/purescript-markdown"
"2020-03-04"
, repo = "https://github.com/poorscript/purescript-markdown"
, version = "2020-03-04"
}
, markdown-smolder =
mkPackage
{ dependencies =
[ "markdown", "smolder" ]
"https://github.com/poorscript/purescript-markdown-smolder"
"2020-03-04"
, repo = "https://github.com/poorscript/purescript-markdown-smolder"
, version = "2020-03-04"
}
, precise =
mkPackage
{ dependencies =
[ "prelude" ]
"https://github.com/purescript-contrib/purescript-precise"
"v4.0.0"
, repo = "https://github.com/purescript-contrib/purescript-precise"
, version = "v4.0.0"
}
, reactix =
mkPackage
{ dependencies =
[ "aff"
, "dom-simple"
, "effect"
......@@ -108,20 +112,23 @@ let additions =
, "prelude"
, "unsafe-coerce"
]
"https://github.com/irresponsible/purescript-reactix"
"v0.4.6"
, repo = "https://github.com/irresponsible/purescript-reactix"
, version = "v0.4.6"
}
, tuples-native =
mkPackage
{ dependencies =
[ "generics-rep", "prelude", "typelevel", "unsafe-coerce" ]
"https://github.com/athanclark/purescript-tuples-native"
"v2.0.1"
, repo = "https://github.com/athanclark/purescript-tuples-native"
, version = "v2.0.1"
}
, uint =
mkPackage
{ dependencies =
[ "maybe", "math", "generics-rep" ]
"https://github.com/zaquest/purescript-uint"
"v5.1.1"
, repo = "https://github.com/zaquest/purescript-uint"
, version = "v5.1.1"
}
, uri =
mkPackage
{ dependencies =
[ "these"
, "arrays"
, "profunctor-lenses"
......@@ -131,23 +138,27 @@ let additions =
, "globals"
, "generics-rep"
]
"https://github.com/slamdata/purescript-uri"
"v7.0.0"
, repo = "https://github.com/slamdata/purescript-uri"
, version = "v7.0.0"
}
, read =
mkPackage
{ dependencies =
[ "prelude", "maybe", "strings" ]
"https://github.com/truqu/purescript-read"
"v1.0.1"
, repo = "https://github.com/truqu/purescript-read"
, version = "v1.0.1"
}
, versions =
mkPackage
{ dependencies =
[ "prelude" ]
"https://github.com/hdgarrood/purescript-versions.git"
"v5.0.1"
, repo = "https://github.com/hdgarrood/purescript-versions.git"
, version = "v5.0.1"
}
, simplecrypto =
mkPackage
{ dependencies =
[ "prelude", "maybe", "node-buffer"]
"https://github.com/alpacaaa/purescript-simplecrypto"
"v1.0.1"
, repo = "https://github.com/alpacaaa/purescript-simplecrypto"
, version = "v1.0.1"
}
}
in upstream ⫽ overrides ⫽ additions
......@@ -381,7 +381,7 @@ pagePaintCpt = R.hooksComponentWithModule thisModule "pagePaintCpt" cpt where
{ colNames
, container: T.defaultContainer { title: "Documents" }
, params
, rows: Seq.fromFoldable $ rows localCategories
, rows: rows localCategories
, totalRecords
, wrapColElts
}
......
......@@ -9,6 +9,7 @@ import Data.Array (concat, filter)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Sequence (Seq)
import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set as Set
......@@ -182,7 +183,7 @@ type PagePath = { nodeId :: Int
initialPagePath :: {session :: Session, nodeId :: Int, listId :: Int, query :: SearchQuery} -> PagePath
initialPagePath {session, nodeId, listId, query} = {session, nodeId, listId, query, params: T.initialParams}
loadPage :: PagePath -> Aff (Array DocumentsView)
loadPage :: PagePath -> Aff (Seq DocumentsView)
loadPage {session, nodeId, listId, query, params: {limit, offset, orderBy, searchType}} = do
let
convOrderBy (T.ASC (T.ColumnName "Date")) = DateAsc
......@@ -198,80 +199,75 @@ loadPage {session, nodeId, listId, query, params: {limit, offset, orderBy, searc
--SearchResult {result} <- post session p $ SearchQuery {query: concat query, expected:searchType}
SearchResult {result} <- post session p query
-- $ SearchQuery {query: concat query, expected: SearchDoc}
pure $ case result of
SearchResultDoc {docs} -> docs2view docs
SearchResultContact {contacts} -> contacts2view contacts
errMessage -> err2view errMessage
docs2view :: Array Document -> Array DocumentsView
docs2view docs = map toView docs
where
toView :: Document -> DocumentsView
toView ( Document { id
, created: date
, hyperdata: HyperdataRowDocument { authors
, title
, source
, publication_year
, publication_month
, publication_day
pure case result of
SearchResultDoc {docs} -> doc2view <$> Seq.fromFoldable docs
SearchResultContact {contacts} -> contact2view <$> Seq.fromFoldable contacts
errMessage -> pure $ err2view errMessage
doc2view :: Document -> DocumentsView
doc2view ( Document { id
, created: date
, hyperdata: HyperdataRowDocument { authors
, title
, source
, publication_year
, publication_month
, publication_day
}
, category
, score
}
) = DocumentsView { id
, date
, title: fromMaybe "Title" title
, source: fromMaybe "Source" source
, score
, authors: fromMaybe "Authors" authors
, category: decodeCategory category
, pairs: []
, delete: false
, publication_year : fromMaybe 2020 publication_year
, publication_month: fromMaybe 1 publication_month
, publication_day : fromMaybe 1 publication_day
}
contact2view :: Contact -> DocumentsView
contact2view (Contact { c_id
, c_created: date
, c_hyperdata: HyperdataRowContact { firstname
, lastname
, labs
}
, category
, score
}
) = DocumentsView { id
, date
, title: fromMaybe "Title" title
, source: fromMaybe "Source" source
, score
, authors: fromMaybe "Authors" authors
, category: decodeCategory category
, pairs: []
, delete: false
, publication_year : fromMaybe 2020 publication_year
, publication_month: fromMaybe 1 publication_month
, publication_day : fromMaybe 1 publication_day
}
contacts2view contacts = map toView contacts
where
toView :: Contact -> DocumentsView
toView (Contact { c_id
, c_created: date
, c_hyperdata: HyperdataRowContact { firstname
, lastname
, labs
}
, c_score
}
) = DocumentsView { id: c_id
, date
, title : firstname <> lastname
, source: labs
, score: c_score
, authors: labs
, category: decodeCategory 1
, pairs: []
, delete: false
, publication_year: 2020
, publication_month: 10
, publication_day: 1
}
, c_score
}
) = DocumentsView { id: c_id
, date
, title : firstname <> lastname
, source: labs
, score: c_score
, authors: labs
, category: decodeCategory 1
, pairs: []
, delete: false
, publication_year: 2020
, publication_month: 10
, publication_day: 1
}
err2view message =
[DocumentsView { id: 1
, date: "2020-01-01"
, title : "SearchNoResult"
, source: "Source"
, score: 1
, authors: "Authors"
, category: decodeCategory 1
, pairs: []
, delete: false
, publication_year: 2020
, publication_month: 10
, publication_day: 1
}
]
DocumentsView { id: 1
, date: "2020-01-01"
, title : "SearchNoResult"
, source: "Source"
, score: 1
, authors: "Authors"
, category: decodeCategory 1
, pairs: []
, delete: false
, publication_year: 2020
, publication_month: 10
, publication_day: 1
}
......@@ -285,7 +281,7 @@ type PageLayoutProps =
, path :: R.State PagePath
)
type PageProps = ( documents :: Array DocumentsView | PageLayoutProps )
type PageProps = ( documents :: Seq DocumentsView | PageLayoutProps )
-- | Loads and renders a page
pageLayout :: Record PageLayoutProps -> R.Element
......@@ -323,7 +319,7 @@ pageCpt = R.hooksComponentWithModule thisModule "page" cpt
documentUrl id =
url frontends $ Routes.CorpusDocument (sessionId session) nodeId listId id
comma = H.span {} [ H.text ", " ]
rows = Seq.fromFoldable $ row <$> filter (not <<< isDeleted) documents
rows = row <$> Seq.filter (not <<< isDeleted) documents
row dv@(DocumentsView {id, score, title, source, authors, pairs, delete, category}) =
{ row:
T.makeRow [
......
......@@ -156,6 +156,7 @@ treeCpt = R.hooksComponentWithModule thisModule "tree" cpt
style = if leaf then {color: "#adb5bd"} else {color: ""}
open = not leaf || false {- TODO -}
cs = ngramsTable ^.. ix ngramsDepth.ngrams <<< _NgramsRepoElement <<< _children <<< folded
-- cs has a list is ok, the length is the number of direct children of an ngram which is generally < 10.
forest =
let depth = ngramsDepth.depth + 1 in
......
module Gargantext.Utils.List where
import Data.Ord (class Ord, comparing)
import Data.List as List
import Data.Array as Array
import Gargantext.Prelude
-- same as
-- https://github.com/purescript/purescript-arrays/blob/v5.3.1/src/Data/Array.purs#L715-L715
sortWith :: forall a b. Ord b => (a -> b) -> List.List a -> List.List a
sortWith f l = Array.toUnfoldable $ Array.sortBy (comparing f) $ Array.fromFoldable l
......@@ -7,13 +7,6 @@ import Data.Tuple
import Gargantext.Prelude
reverse :: forall a. Seq a -> Seq a
reverse s = case uncons s of
Nothing -> empty
Just (Tuple x xs) -> snoc (reverse xs) x
mapMaybe :: forall a b. (a -> Maybe b) -> Seq a -> Seq b
mapMaybe f = go empty
where
......
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