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
0d626b03
Commit
0d626b03
authored
Dec 02, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DocsTable] implement count returned in doc search
parent
1832703a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
20 deletions
+21
-20
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+10
-8
Tabs.purs
src/Gargantext/Components/Nodes/Corpus/Graph/Tabs.purs
+1
-2
Types.purs
src/Gargantext/Types.purs
+1
-1
Utils.purs
src/Gargantext/Utils.purs
+0
-8
Math.purs
src/Gargantext/Utils/Math.purs
+7
-0
Spec.purs
test/Gargantext/Utils/Spec.purs
+2
-1
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
0d626b03
...
@@ -179,7 +179,6 @@ _localCategories = prop (SProxy :: SProxy "localCategories")
...
@@ -179,7 +179,6 @@ _localCategories = prop (SProxy :: SProxy "localCategories")
data Action
data Action
= MarkCategory Int Category
= MarkCategory Int Category
newtype DocumentsView
newtype DocumentsView
= DocumentsView
= DocumentsView
{ _id :: Int
{ _id :: Int
...
@@ -329,22 +328,24 @@ type PageParams =
...
@@ -329,22 +328,24 @@ type PageParams =
, query :: Query
, query :: Query
, params :: T.Params}
, params :: T.Params}
loadPage :: Session -> PageParams -> Aff (
Array DocumentsView
)
loadPage :: Session -> PageParams -> Aff (
Tuple Int (Array DocumentsView)
)
loadPage session {nodeId, tabType, query, listId, corpusId, params: {limit, offset, orderBy}} = do
loadPage session {nodeId, tabType, query, listId, corpusId, params: {limit, offset, orderBy}} = do
liftEffect $ log3 "loading documents page: loadPage with Offset and limit" offset limit
liftEffect $ log3 "loading documents page: loadPage with Offset and limit" offset limit
-- res <- get $ toUrl endConfigStateful Back (Tab tabType offset limit (convOrderBy <$> orderBy)) (Just nodeId)
-- res <- get $ toUrl endConfigStateful Back (Tab tabType offset limit (convOrderBy <$> orderBy)) (Just nodeId)
let p = NodeAPI Node (Just nodeId) "table"
let p = NodeAPI Node (Just nodeId) "table"
res <- post session p $ TabPostQuery {
res <-
(
post session p $ TabPostQuery {
offset
offset
, limit
, limit
, orderBy: convOrderBy orderBy
, orderBy: convOrderBy orderBy
, tabType
, tabType
, query
, query
}
}
) :: Aff {count :: Int, docs :: Array Response}
let docs = res2corpus <$> res
let docs = res2corpus <$> res
.docs
pure $
pure $
if mock then take limit $ drop offset sampleData else
if mock then
docs
Tuple 4737 (take limit $ drop offset sampleData)
else
Tuple res.count docs
where
where
res2corpus :: Response -> DocumentsView
res2corpus :: Response -> DocumentsView
res2corpus (Response r) =
res2corpus (Response r) =
...
@@ -374,7 +375,8 @@ pageLayoutCpt = R.memo' $ R.staticComponent "G.C.DocsTable.pageLayout" cpt where
...
@@ -374,7 +375,8 @@ pageLayoutCpt = R.memo' $ R.staticComponent "G.C.DocsTable.pageLayout" cpt where
loader path (loadPage session) paint
loader path (loadPage session) paint
where
where
path = {nodeId, listId, corpusId, tabType, query, params: fst params}
path = {nodeId, listId, corpusId, tabType, query, params: fst params}
paint loaded = page params props loaded
paint (Tuple count docs) = page params (newProps count) docs
newProps count = props { totalRecords = count }
type PageProps =
type PageProps =
( params :: R.State T.Params
( params :: R.State T.Params
...
...
src/Gargantext/Components/Nodes/Corpus/Graph/Tabs.purs
View file @
0d626b03
...
@@ -35,8 +35,7 @@ tab :: Frontends -> Session -> TextQuery -> GraphSideCorpus -> Tuple String R.El
...
@@ -35,8 +35,7 @@ tab :: Frontends -> Session -> TextQuery -> GraphSideCorpus -> Tuple String R.El
tab frontends session query (GraphSideCorpus {corpusId: nodeId, corpusLabel, listId}) =
tab frontends session query (GraphSideCorpus {corpusId: nodeId, corpusLabel, listId}) =
Tuple corpusLabel (docView dvProps)
Tuple corpusLabel (docView dvProps)
where
where
dvProps = {frontends, session, nodeId, listId, query, chart, totalRecords: 4736, container}
dvProps = {frontends, session, nodeId, listId, query, chart, totalRecords: 0, container}
-- TODO totalRecords: probably need to insert a corpusLoader.
chart = mempty
chart = mempty
container = T.graphContainer {title: corpusLabel}
container = T.graphContainer {title: corpusLabel}
src/Gargantext/Types.purs
View file @
0d626b03
...
@@ -2,8 +2,8 @@ module Gargantext.Types where
...
@@ -2,8 +2,8 @@ module Gargantext.Types where
import Prelude
import Prelude
import Data.Argonaut ( class DecodeJson, decodeJson, class EncodeJson, encodeJson, (:=), (~>), jsonEmptyObject)
import Data.Argonaut ( class DecodeJson, decodeJson, class EncodeJson, encodeJson, (:=), (~>), jsonEmptyObject)
import Data.Maybe (Maybe(..), maybe)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Maybe (Maybe(..), maybe)
import Prim.Row (class Union)
import Prim.Row (class Union)
import URI.Query (Query)
import URI.Query (Query)
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep (class Generic)
...
...
src/Gargantext/Utils.purs
View file @
0d626b03
...
@@ -6,7 +6,6 @@ import Data.Newtype (class Newtype, unwrap, wrap)
...
@@ -6,7 +6,6 @@ import Data.Newtype (class Newtype, unwrap, wrap)
import Data.Set as Set
import Data.Set as Set
import Data.Set (Set)
import Data.Set (Set)
import Data.String (length)
import Data.String (length)
import Math (log)
-- | Astonishingly, not in the prelude
-- | Astonishingly, not in the prelude
id :: forall a. a -> a
id :: forall a. a -> a
...
@@ -59,13 +58,6 @@ glyphicon t = "btn glyphitem glyphicon glyphicon-" <> t
...
@@ -59,13 +58,6 @@ glyphicon t = "btn glyphitem glyphicon glyphicon-" <> t
glyphiconActive :: String -> Boolean -> String
glyphiconActive :: String -> Boolean -> String
glyphiconActive icon b = glyphicon icon <> if b then " active" else ""
glyphiconActive icon b = glyphicon icon <> if b then " active" else ""
-- | Logarithm with given base
logb :: Number -> Number -> Number
logb base n = (log n) / (log base)
log10 :: Number -> Number
log10 = logb 10.0
-- | Format a number with specified amount of zero-padding
-- | Format a number with specified amount of zero-padding
zeroPad :: Int -> Int -> String
zeroPad :: Int -> Int -> String
zeroPad pad num = zeros <> (show num)
zeroPad pad num = zeros <> (show num)
...
...
src/Gargantext/Utils/Math.purs
View file @
0d626b03
...
@@ -5,3 +5,10 @@ import Math as Math
...
@@ -5,3 +5,10 @@ import Math as Math
roundToMultiple :: Number -> Number -> Number
roundToMultiple :: Number -> Number -> Number
roundToMultiple eps num = eps * Math.round (num / eps)
roundToMultiple eps num = eps * Math.round (num / eps)
-- | Logarithm with given base
logb :: Number -> Number -> Number
logb base n = (Math.log n) / (Math.log base)
log10 :: Number -> Number
log10 = logb 10.0
test/Gargantext/Utils/Spec.purs
View file @
0d626b03
...
@@ -7,6 +7,7 @@ import Data.Maybe (Maybe(..), isJust)
...
@@ -7,6 +7,7 @@ import Data.Maybe (Maybe(..), isJust)
import Data.String (drop, stripPrefix, Pattern(..))
import Data.String (drop, stripPrefix, Pattern(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Gargantext.Utils as U
import Gargantext.Utils as U
import Gargantext.Utils.Math as UM
-- import Test.QuickCheck ((===), (/==), (<?>), Result(..))
-- import Test.QuickCheck ((===), (/==), (<?>), Result(..))
import Test.Spec (Spec, describe, it)
import Test.Spec (Spec, describe, it)
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Assertions (shouldEqual)
...
@@ -33,4 +34,4 @@ spec =
...
@@ -33,4 +34,4 @@ spec =
U.zeroPad 3 101 `shouldEqual` "101"
U.zeroPad 3 101 `shouldEqual` "101"
U.zeroPad 3 1000 `shouldEqual` "1000"
U.zeroPad 3 1000 `shouldEqual` "1000"
it "log10 10" do
it "log10 10" do
U.log10 10.0 `shouldEqual` 1.0
U
M
.log10 10.0 `shouldEqual` 1.0
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