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
Grégoire Locqueville
purescript-gargantext
Commits
803fbe8a
Commit
803fbe8a
authored
Oct 12, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] change List to Seq in ngrams table
parent
4f48d780
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
29 deletions
+60
-29
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+9
-9
FacetsTable.purs
src/Gargantext/Components/FacetsTable.purs
+3
-3
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+11
-11
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+2
-2
Table.purs
src/Gargantext/Components/Table.purs
+4
-4
Seq.purs
src/Gargantext/Utils/Seq.purs
+31
-0
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
803fbe8a
...
@@ -9,11 +9,11 @@ import Data.Generic.Rep.Show (genericShow)
...
@@ -9,11 +9,11 @@ import Data.Generic.Rep.Show (genericShow)
import Data.Lens ((^.))
import Data.Lens ((^.))
import Data.Lens.At (at)
import Data.Lens.At (at)
import Data.Lens.Record (prop)
import Data.Lens.Record (prop)
import Data.List as L
import Data.Map (Map)
import Data.Map (Map)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..), fromMaybe, isJust)
import Data.Maybe (Maybe(..), fromMaybe, isJust)
import Data.Ord.Down (Down(..))
import Data.Ord.Down (Down(..))
import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
import Data.String as Str
import Data.String as Str
...
@@ -32,7 +32,7 @@ import Gargantext.Components.Category
...
@@ -32,7 +32,7 @@ import Gargantext.Components.Category
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Ends (Frontends, url)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Hooks.Loader (useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Utils.
List (sortWith) as L
import Gargantext.Utils.
Seq (sortWith) as Seq
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes
import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes (SessionRoute(NodeAPI))
...
@@ -359,7 +359,7 @@ pagePaintCpt = R2.hooksComponent thisModule "pagePaintCpt" cpt where
...
@@ -359,7 +359,7 @@ pagePaintCpt = R2.hooksComponent thisModule "pagePaintCpt" cpt where
{ colNames
{ colNames
, container: T.defaultContainer { title: "Documents" }
, container: T.defaultContainer { title: "Documents" }
, params
, params
, rows:
L
.fromFoldable $ rows localCategories
, rows:
Seq
.fromFoldable $ rows localCategories
, totalRecords
, totalRecords
, wrapColElts
, wrapColElts
}
}
...
@@ -377,12 +377,12 @@ pagePaintCpt = R2.hooksComponent thisModule "pagePaintCpt" cpt where
...
@@ -377,12 +377,12 @@ pagePaintCpt = R2.hooksComponent thisModule "pagePaintCpt" cpt where
getCategory (localCategories /\ _) {_id, category} = fromMaybe category (localCategories ^. at _id)
getCategory (localCategories /\ _) {_id, category} = fromMaybe category (localCategories ^. at _id)
orderWith =
orderWith =
case convOrderBy (fst params).orderBy of
case convOrderBy (fst params).orderBy of
Just DateAsc ->
L
.sortWith \(DocumentsView { date }) -> date
Just DateAsc ->
Seq
.sortWith \(DocumentsView { date }) -> date
Just DateDesc ->
L
.sortWith \(DocumentsView { date }) -> Down date
Just DateDesc ->
Seq
.sortWith \(DocumentsView { date }) -> Down date
Just SourceAsc ->
L
.sortWith \(DocumentsView { source }) -> Str.toLower source
Just SourceAsc ->
Seq
.sortWith \(DocumentsView { source }) -> Str.toLower source
Just SourceDesc ->
L
.sortWith \(DocumentsView { source }) -> Down $ Str.toLower source
Just SourceDesc ->
Seq
.sortWith \(DocumentsView { source }) -> Down $ Str.toLower source
Just TitleAsc ->
L
.sortWith \(DocumentsView { title }) -> Str.toLower title
Just TitleAsc ->
Seq
.sortWith \(DocumentsView { title }) -> Str.toLower title
Just TitleDesc ->
L
.sortWith \(DocumentsView { title }) -> Down $ Str.toLower title
Just TitleDesc ->
Seq
.sortWith \(DocumentsView { title }) -> Down $ Str.toLower title
_ -> identity -- the server ordering is enough here
_ -> identity -- the server ordering is enough here
filteredRows = T.filterRows { params: fst params } $ orderWith $ A.toUnfoldable documents
filteredRows = T.filterRows { params: fst params } $ orderWith $ A.toUnfoldable documents
rows localCategories = row <$> filteredRows
rows localCategories = row <$> filteredRows
...
...
src/Gargantext/Components/FacetsTable.purs
View file @
803fbe8a
...
@@ -8,11 +8,11 @@ import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyO
...
@@ -8,11 +8,11 @@ import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, jsonEmptyO
import Data.Array (concat, filter)
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.List as L
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set (Set)
import Data.String as String
import Data.Set as Set
import Data.Set as Set
import Data.String as String
import Data.Tuple (fst, snd)
import Data.Tuple (fst, snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect (Effect)
...
@@ -323,7 +323,7 @@ pageCpt = R2.hooksComponent thisModule "page" cpt
...
@@ -323,7 +323,7 @@ pageCpt = R2.hooksComponent 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 =
L
.fromFoldable $ row <$> filter (not <<< isDeleted) documents
rows =
Seq
.fromFoldable $ row <$> 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 [
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
803fbe8a
...
@@ -11,12 +11,12 @@ import Data.Lens.Common (_Just)
...
@@ -11,12 +11,12 @@ import Data.Lens.Common (_Just)
import Data.Lens.Fold (folded)
import Data.Lens.Fold (folded)
import Data.Lens.Index (ix)
import Data.Lens.Index (ix)
import Data.Lens.Record (prop)
import Data.Lens.Record (prop)
import Data.List (List, mapMaybe, length) as L
import Data.Map (Map)
import Data.Map (Map)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..), isNothing, maybe)
import Data.Maybe (Maybe(..), isNothing, maybe)
import Data.Monoid.Additive (Additive(..))
import Data.Monoid.Additive (Additive(..))
import Data.Ord.Down (Down(..))
import Data.Ord.Down (Down(..))
import Data.Sequence as Seq
import Data.Set (Set)
import Data.Set (Set)
import Data.Set as Set
import Data.Set as Set
import Data.Symbol (SProxy(..))
import Data.Symbol (SProxy(..))
...
@@ -41,8 +41,8 @@ import Gargantext.Sessions (Session, get)
...
@@ -41,8 +41,8 @@ import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
import Gargantext.Utils (queryMatchesLabel, toggleSet)
import Gargantext.Utils (queryMatchesLabel, toggleSet)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.List (sortWith) as L
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Seq as Seq
thisModule = "Gargantext.Components.NgramsTable"
thisModule = "Gargantext.Components.NgramsTable"
...
@@ -116,7 +116,7 @@ setTermListSetA ngramsTable ns new_list =
...
@@ -116,7 +116,7 @@ setTermListSetA ngramsTable ns new_list =
addNewNgramA :: NgramsTerm -> Action
addNewNgramA :: NgramsTerm -> Action
addNewNgramA ngram = CommitPatch $ addNewNgram ngram CandidateTerm
addNewNgramA ngram = CommitPatch $ addNewNgram ngram CandidateTerm
type PreConversionRows =
L.List
NgramsElement
type PreConversionRows =
Seq.Seq
NgramsElement
type TableContainerProps =
type TableContainerProps =
( dispatch :: Dispatch
( dispatch :: Dispatch
...
@@ -381,7 +381,7 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
...
@@ -381,7 +381,7 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
setState $ setParentResetChildren Nothing
setState $ setParentResetChildren Nothing
commitPatchR (Versioned {version: ngramsVersion, data: pt}) (state /\ setState)
commitPatchR (Versioned {version: ngramsVersion, data: pt}) (state /\ setState)
totalRecords =
L
.length rows
totalRecords =
Seq
.length rows
filteredConvertedRows :: T.Rows
filteredConvertedRows :: T.Rows
filteredConvertedRows = convertRow <$> filteredRows
filteredConvertedRows = convertRow <$> filteredRows
filteredRows :: PreConversionRows
filteredRows :: PreConversionRows
...
@@ -390,9 +390,9 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
...
@@ -390,9 +390,9 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
ng_scores = ngramsTable ^. _NgramsTable <<< _ngrams_scores
ng_scores = ngramsTable ^. _NgramsTable <<< _ngrams_scores
rows :: PreConversionRows
rows :: PreConversionRows
rows = orderWith (
rows = orderWith (
L
.mapMaybe (\(Tuple ng nre) ->
Seq
.mapMaybe (\(Tuple ng nre) ->
let Additive s = ng_scores ^. at ng <<< _Just in
let Additive s = ng_scores ^. at ng <<< _Just in
addOcc <$> rowsFilter (ngramsRepoElementToNgramsElement ng s nre)) $
addOcc <$> rowsFilter (ngramsRepoElementToNgramsElement ng s nre)) $
Map.toUnfoldable (ngramsTable ^. _NgramsTable <<< _ngrams_repo_elements)
Map.toUnfoldable (ngramsTable ^. _NgramsTable <<< _ngrams_repo_elements)
)
)
rowsFilter :: NgramsElement -> Maybe NgramsElement
rowsFilter :: NgramsElement -> Maybe NgramsElement
...
@@ -430,10 +430,10 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
...
@@ -430,10 +430,10 @@ loadedNgramsTableCpt = R2.hooksComponent thisModule "loadedNgramsTable" cpt
}
}
orderWith =
orderWith =
case convOrderBy <$> params.orderBy of
case convOrderBy <$> params.orderBy of
Just ScoreAsc ->
L
.sortWith \x -> x ^. _NgramsElement <<< _occurrences
Just ScoreAsc ->
Seq
.sortWith \x -> x ^. _NgramsElement <<< _occurrences
Just ScoreDesc ->
L
.sortWith \x -> Down $ x ^. _NgramsElement <<< _occurrences
Just ScoreDesc ->
Seq
.sortWith \x -> Down $ x ^. _NgramsElement <<< _occurrences
Just TermAsc ->
L
.sortWith \x -> x ^. _NgramsElement <<< _ngrams
Just TermAsc ->
Seq
.sortWith \x -> x ^. _NgramsElement <<< _ngrams
Just TermDesc ->
L
.sortWith \x -> Down $ x ^. _NgramsElement <<< _ngrams
Just TermDesc ->
Seq
.sortWith \x -> Down $ x ^. _NgramsElement <<< _ngrams
_ -> identity -- the server ordering is enough here
_ -> identity -- the server ordering is enough here
colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy
colNames = T.ColumnName <$> ["Select", "Map", "Stop", "Terms", "Score"] -- see convOrderBy
...
...
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
803fbe8a
...
@@ -3,8 +3,8 @@ module Gargantext.Components.Nodes.Annuaire where
...
@@ -3,8 +3,8 @@ module Gargantext.Components.Nodes.Annuaire where
import Prelude (bind, const, identity, pure, show, ($), (<$>), (<>))
import Prelude (bind, const, identity, pure, show, ($), (<$>), (<>))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Array as A
import Data.Array as A
import Data.List as L
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Sequence as Seq
import Data.Tuple (fst, snd)
import Data.Tuple (fst, snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff_)
import Effect.Aff (Aff, launchAff_)
...
@@ -156,7 +156,7 @@ pageCpt = R2.hooksComponent thisModule "page" cpt
...
@@ -156,7 +156,7 @@ pageCpt = R2.hooksComponent thisModule "page" cpt
, frontends
, frontends
, contact: c
, contact: c
, session }
, session }
, delete: false }) <$>
L
.fromFoldable docs
, delete: false }) <$>
Seq
.fromFoldable docs
container = T.defaultContainer { title: "Annuaire" } -- TODO
container = T.defaultContainer { title: "Annuaire" } -- TODO
colNames = T.ColumnName <$> [ "", "First Name", "Last Name", "Company", "Lab", "Role"]
colNames = T.ColumnName <$> [ "", "First Name", "Last Name", "Company", "Lab", "Role"]
wrapColElts = const identity
wrapColElts = const identity
...
...
src/Gargantext/Components/Table.purs
View file @
803fbe8a
...
@@ -4,8 +4,8 @@ import Prelude
...
@@ -4,8 +4,8 @@ import Prelude
import Data.Array as A
import Data.Array as A
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.List as L
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Sequence as Seq
import Data.Tuple (fst, snd)
import Data.Tuple (fst, snd)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import DOM.Simple.Console (log2)
...
@@ -29,7 +29,7 @@ type TableContainerProps =
...
@@ -29,7 +29,7 @@ type TableContainerProps =
)
)
type Row = { row :: R.Element, delete :: Boolean }
type Row = { row :: R.Element, delete :: Boolean }
type Rows =
L.List
Row
type Rows =
Seq.Seq
Row
type OrderBy = Maybe (OrderByDirection ColumnName)
type OrderBy = Maybe (OrderByDirection ColumnName)
...
@@ -199,10 +199,10 @@ type FilterRowsParams =
...
@@ -199,10 +199,10 @@ type FilterRowsParams =
params :: Params
params :: Params
)
)
filterRows :: forall a. Record FilterRowsParams ->
L.List a -> L.List
a
filterRows :: forall a. Record FilterRowsParams ->
Seq.Seq a -> Seq.Seq
a
filterRows { params: { limit, offset, orderBy } } rs = newRs
filterRows { params: { limit, offset, orderBy } } rs = newRs
where
where
newRs =
L.take limit $ L
.drop offset $ rs
newRs =
Seq.take limit $ Seq
.drop offset $ rs
defaultContainer :: {title :: String} -> Record TableContainerProps -> R.Element
defaultContainer :: {title :: String} -> Record TableContainerProps -> R.Element
defaultContainer {title} props = R.fragment
defaultContainer {title} props = R.fragment
...
...
src/Gargantext/Utils/Seq.purs
0 → 100644
View file @
803fbe8a
module Gargantext.Utils.Seq where
import Data.Array as Array
import Data.Maybe
import Data.Sequence
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
go acc s =
case uncons s of
Nothing -> reverse acc
Just (Tuple x xs) ->
case f x of
Nothing -> go acc xs
Just y -> go (cons y acc) xs
-- 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) -> Seq a -> Seq a
sortWith f l = Array.toUnfoldable $ Array.sortBy (comparing f) $ Array.fromFoldable l
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