Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-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
purescript-gargantext
Commits
b89c20ae
Commit
b89c20ae
authored
Oct 14, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor: use directly Seq instead of Array here
parent
2d81fdd5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
74 deletions
+70
-74
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+70
-74
No files found.
src/Gargantext/Components/FacetsTable.purs
View file @
b89c20ae
...
@@ -9,6 +9,7 @@ import Data.Array (concat, filter)
...
@@ -9,6 +9,7 @@ import Data.Array (concat, filter)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Sequence (Seq)
import Data.Sequence as Seq
import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
...
@@ -182,7 +183,7 @@ type PagePath = { nodeId :: Int
...
@@ -182,7 +183,7 @@ type PagePath = { nodeId :: Int
initialPagePath :: {session :: Session, nodeId :: Int, listId :: Int, query :: SearchQuery} -> PagePath
initialPagePath :: {session :: Session, nodeId :: Int, listId :: Int, query :: SearchQuery} -> PagePath
initialPagePath {session, nodeId, listId, query} = {session, nodeId, listId, query, params: T.initialParams}
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
loadPage {session, nodeId, listId, query, params: {limit, offset, orderBy, searchType}} = do
let
let
convOrderBy (T.ASC (T.ColumnName "Date")) = DateAsc
convOrderBy (T.ASC (T.ColumnName "Date")) = DateAsc
...
@@ -198,80 +199,75 @@ loadPage {session, nodeId, listId, query, params: {limit, offset, orderBy, searc
...
@@ -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 $ SearchQuery {query: concat query, expected:searchType}
SearchResult {result} <- post session p query
SearchResult {result} <- post session p query
-- $ SearchQuery {query: concat query, expected: SearchDoc}
-- $ SearchQuery {query: concat query, expected: SearchDoc}
pure $ case result of
pure case result of
SearchResultDoc {docs} -> docs2view docs
SearchResultDoc {docs} -> doc2view <$> Seq.fromFoldable docs
SearchResultContact {contacts} -> contacts2view contacts
SearchResultContact {contacts} -> contact2view <$> Seq.fromFoldable contacts
errMessage -> err2view errMessage
errMessage -> pure $ err2view errMessage
docs2view :: Array Document -> Array DocumentsView
doc2view :: Document -> DocumentsView
docs2view docs = map toView docs
doc2view ( Document { id
where
, created: date
toView :: Document -> DocumentsView
, hyperdata: HyperdataRowDocument { authors
toView ( Document { id
, title
, created: date
, source
, hyperdata: HyperdataRowDocument { authors
, publication_year
, title
, publication_month
, source
, publication_day
, publication_year
}
, publication_month
, category
, publication_day
, 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
, c_score
, score
}
}
) = DocumentsView { id: c_id
) = DocumentsView { id
, date
, date
, title : firstname <> lastname
, title: fromMaybe "Title" title
, source: labs
, source: fromMaybe "Source" source
, score: c_score
, score
, authors: labs
, authors: fromMaybe "Authors" authors
, category: decodeCategory 1
, category: decodeCategory category
, pairs: []
, pairs: []
, delete: false
, delete: false
, publication_year: 2020
, publication_year : fromMaybe 2020 publication_year
, publication_month: 10
, publication_month: fromMaybe 1 publication_month
, publication_day: 1
, 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
}
err2view message =
err2view message =
[DocumentsView { id: 1
DocumentsView { id: 1
, date: "2020-01-01"
, date: "2020-01-01"
, title : "SearchNoResult"
, title : "SearchNoResult"
, source: "Source"
, source: "Source"
, score: 1
, score: 1
, authors: "Authors"
, authors: "Authors"
, category: decodeCategory 1
, category: decodeCategory 1
, pairs: []
, pairs: []
, delete: false
, delete: false
, publication_year: 2020
, publication_year: 2020
, publication_month: 10
, publication_month: 10
, publication_day: 1
, publication_day: 1
}
}
]
...
@@ -285,7 +281,7 @@ type PageLayoutProps =
...
@@ -285,7 +281,7 @@ type PageLayoutProps =
, path :: R.State PagePath
, path :: R.State PagePath
)
)
type PageProps = ( documents ::
Array
DocumentsView | PageLayoutProps )
type PageProps = ( documents ::
Seq
DocumentsView | PageLayoutProps )
-- | Loads and renders a page
-- | Loads and renders a page
pageLayout :: Record PageLayoutProps -> R.Element
pageLayout :: Record PageLayoutProps -> R.Element
...
@@ -323,7 +319,7 @@ pageCpt = R.hooksComponentWithModule thisModule "page" cpt
...
@@ -323,7 +319,7 @@ pageCpt = R.hooksComponentWithModule thisModule "page" cpt
documentUrl id =
documentUrl id =
url frontends $ Routes.CorpusDocument (sessionId session) nodeId listId id
url frontends $ Routes.CorpusDocument (sessionId session) nodeId listId id
comma = H.span {} [ H.text ", " ]
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 dv@(DocumentsView {id, score, title, source, authors, pairs, delete, category}) =
{ row:
{ row:
T.makeRow [
T.makeRow [
...
...
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