Commit e41bad51 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FACET] Corpus ok.

parent 4a70c663
...@@ -70,8 +70,9 @@ corpusTree = NodeT Corpus ( [ leafT Document ] ...@@ -70,8 +70,9 @@ corpusTree = NodeT Corpus ( [ leafT Document ]
-- * why NodeUser and not just User ? -- * why NodeUser and not just User ?
-- * is this supposed to hold data ? -- * is this supposed to hold data ?
data Parent = NodeType NodeId
data Classification = Favorites | MyClassifcation --data Classification = Favorites | MyClassifcation
data Lists = StopList | MainList | MapList | GroupList data Lists = StopList | MainList | MapList | GroupList
...@@ -144,7 +145,7 @@ nodeTypes = [ (NodeUser , 1) ...@@ -144,7 +145,7 @@ nodeTypes = [ (NodeUser , 1)
-- , (TirankGlobal , 17) -- , (TirankGlobal , 17)
-- --
---- Node management ---- Node management
-- , (Favorites , 15) , (Favorites , 15)
-- --
] ]
-- --
......
...@@ -236,7 +236,7 @@ type Corpus = Node HyperdataCorpus ...@@ -236,7 +236,7 @@ type Corpus = Node HyperdataCorpus
type Document = Node HyperdataDocument type Document = Node HyperdataDocument
------------------------------------------------------------------------ ------------------------------------------------------------------------
data NodeType = NodeUser | Project | Folder | Corpus | Annuaire | Document | UserPage | DocumentCopy data NodeType = NodeUser | Project | Folder | Corpus | Annuaire | Document | UserPage | DocumentCopy | Favorites
| Classification | Classification
| Lists | Lists
| Metrics | Occurrences | Metrics | Occurrences
......
...@@ -125,19 +125,19 @@ instance Arbitrary FacetChart where ...@@ -125,19 +125,19 @@ instance Arbitrary FacetChart where
----------------------------------------------------------------------- -----------------------------------------------------------------------
getDocFacet :: Connection -> Int -> Maybe NodeType getDocFacet :: Connection -> NodeType -> Int -> Maybe NodeType
-> Maybe Offset -> Maybe Limit -> Maybe Offset -> Maybe Limit
-> IO [FacetDoc] -> IO [FacetDoc]
getDocFacet conn parentId nodeType maybeOffset maybeLimit = getDocFacet conn parentType parentId nodeType maybeOffset maybeLimit =
runQuery conn $ selectDocFacet parentId nodeType maybeOffset maybeLimit runQuery conn $ selectDocFacet parentType parentId nodeType maybeOffset maybeLimit
selectDocFacet :: ParentId -> Maybe NodeType selectDocFacet :: NodeType -> ParentId -> Maybe NodeType
-> Maybe Offset -> Maybe Limit -> Maybe Offset -> Maybe Limit
-> Query FacetDocRead -> Query FacetDocRead
selectDocFacet parentId maybeNodeType maybeOffset maybeLimit = selectDocFacet pType parentId maybeNodeType maybeOffset maybeLimit =
limit' maybeLimit $ offset' maybeOffset limit' maybeLimit $ offset' maybeOffset
$ orderBy (asc facetDoc_created) $ orderBy (asc facetDoc_created)
$ selectDocFacet' parentId maybeNodeType $ selectDocFacet' pType parentId maybeNodeType
-- | Left join to the favorites -- | Left join to the favorites
...@@ -215,25 +215,21 @@ leftJoin3''' = leftJoin3 queryNodeNodeTable queryNodeTable queryNodeTable cond12 ...@@ -215,25 +215,21 @@ leftJoin3''' = leftJoin3 queryNodeNodeTable queryNodeTable queryNodeTable cond12
= ((.==) (nId) (nId')) = ((.==) (nId) (nId'))
-- getDocTest :: Connection -> IO [FacetDoc]
-- getDocTest conn = runQuery conn selectDocFacet
-- | Building the facet -- | Building the facet
-- selectDocFacet' :: ParentId -> Maybe NodeType -> Query FacetDocRead selectDocFacet' :: NodeType -> ParentId -> Maybe NodeType -> Query FacetDocRead
selectDocFacet' :: ParentId -> Maybe NodeType -> Query FacetDocRead selectDocFacet' pt pId _ = proc () -> do
selectDocFacet' _ _ = proc () -> do
(n1,(nn,n2)) <- leftJoin3''' -< () (n1,(nn,n2)) <- leftJoin3''' -< ()
restrict -< (.&&) (node_parentId n1 .== (toNullable $ pgInt4 347476)) restrict -< (.&&) (node_parentId n1 .== (toNullable $ pgInt4 pId))
(node_typename n1 .== (pgInt4 4)) (node_typename n1 .== (pgInt4 $ nodeTypeId Document))
restrict -< (.||) (node_typename n2 .== (toNullable $ pgInt4 15)) restrict -< (.||) (node_typename n2 .== (toNullable $ pgInt4 $ nodeTypeId Favorites))
(isNull $ node_typename n2) (isNull $ node_typename n2)
restrict -< (.||) (node_parentId n2 .== (toNullable $ pgInt4 347476)) restrict -< (.||) (node_parentId n2 .== (toNullable $ pgInt4 $ nodeTypeId Favorites))
(isNull $ node_parentId n2) (isNull $ node_parentId n2)
let isFav = ifThenElse (isNull $ nodeNode_score nn) (pgBool False) (pgBool True) let isFav = ifThenElse (isNull $ nodeNode_score nn) (pgBool False) (pgBool True)
--
returnA -< FacetDoc (node_id n1) (node_date n1) (node_hyperdata n1) (isFav) (pgInt4 1) returnA -< FacetDoc (node_id n1) (node_date n1) (node_hyperdata n1) (isFav) (pgInt4 1)
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