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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
gargantext
haskell-gargantext
Commits
a7ed762a
Unverified
Commit
a7ed762a
authored
May 16, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[docs table] order by source
parent
85a70600
Pipeline
#390
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
10 deletions
+21
-10
Facet.hs
src/Gargantext/Database/Facet.hs
+21
-10
No files found.
src/Gargantext/Database/Facet.hs
View file @
a7ed762a
...
...
@@ -23,6 +23,7 @@ Portability : POSIX
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
------------------------------------------------------------------------
module
Gargantext.Database.Facet
where
...
...
@@ -171,17 +172,20 @@ type Trash = Bool
data
OrderBy
=
DateAsc
|
DateDesc
|
TitleAsc
|
TitleDesc
|
ScoreDesc
|
ScoreAsc
|
SourceAsc
|
SourceDesc
deriving
(
Generic
,
Enum
,
Bounded
,
Read
,
Show
)
instance
FromHttpApiData
OrderBy
where
parseUrlPiece
"DateAsc"
=
pure
DateAsc
parseUrlPiece
"DateDesc"
=
pure
DateDesc
parseUrlPiece
"TitleAsc"
=
pure
TitleAsc
parseUrlPiece
"TitleDesc"
=
pure
TitleDesc
parseUrlPiece
"DateAsc"
=
pure
DateAsc
parseUrlPiece
"DateDesc"
=
pure
DateDesc
parseUrlPiece
"TitleAsc"
=
pure
TitleAsc
parseUrlPiece
"TitleDesc"
=
pure
TitleDesc
parseUrlPiece
"ScoreAsc"
=
pure
ScoreAsc
parseUrlPiece
"ScoreDesc"
=
pure
ScoreDesc
parseUrlPiece
_
=
Left
"Unexpected value of OrderBy"
parseUrlPiece
"SourceAsc"
=
pure
SourceAsc
parseUrlPiece
"SourceDesc"
=
pure
SourceDesc
parseUrlPiece
_
=
Left
"Unexpected value of OrderBy"
instance
ToParamSchema
OrderBy
instance
FromJSON
OrderBy
...
...
@@ -250,7 +254,7 @@ viewDocuments cId t ntId = proc () -> do
------------------------------------------------------------------------
filterWith
::
(
PGOrd
date
,
PGOrd
title
,
PGOrd
score
)
=>
filterWith
::
(
PGOrd
date
,
PGOrd
title
,
PGOrd
score
,
hyperdata
~
Column
SqlJsonb
)
=>
Maybe
Gargantext
.
Core
.
Types
.
Offset
->
Maybe
Gargantext
.
Core
.
Types
.
Limit
->
Maybe
OrderBy
...
...
@@ -261,15 +265,22 @@ filterWith o l order q = limit' l $ offset' o $ orderBy (orderWith order) q
orderWith
::
(
PGOrd
b1
,
PGOrd
b2
,
PGOrd
b3
)
=>
Maybe
OrderBy
->
Order
(
Facet
id
(
Column
b1
)
(
Column
b2
)
hyperdata
(
Column
b3
)
score
)
->
Order
(
Facet
id
(
Column
b1
)
(
Column
b2
)
(
Column
SqlJsonb
)
(
Column
b3
)
score
)
orderWith
(
Just
DateAsc
)
=
asc
facetDoc_created
orderWith
(
Just
DateDesc
)
=
desc
facetDoc_created
orderWith
(
Just
TitleAsc
)
=
asc
facetDoc_title
orderWith
(
Just
TitleDesc
)
=
desc
facetDoc_title
orderWith
(
Just
ScoreAsc
)
=
asc
facetDoc_favorite
orderWith
(
Just
ScoreDesc
)
=
desc
facetDoc_favorite
orderWith
(
Just
SourceAsc
)
=
asc
facetDoc_source
orderWith
(
Just
SourceDesc
)
=
desc
facetDoc_source
orderWith
_
=
asc
facetDoc_created
facetDoc_source
::
PGIsJson
a
=>
Facet
id
created
title
(
Column
a
)
favorite
ngramCount
->
Column
(
Nullable
PGText
)
facetDoc_source
x
=
toNullable
(
facetDoc_hyperdata
x
)
.->>
pgString
"source"
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