ContextNodeNgrams.hs 2.67 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
{-|
Module      : Gargantext.Database.Schema.NodeNodeNgrams
Description : TODO: remove this module and table in database
Copyright   : (c) CNRS, 2017-Present
License     : AGPL + CECILL v3
Maintainer  : team@gargantext.org
Stability   : experimental
Portability : POSIX

-}

{-#  OPTIONS_GHC -fno-warn-orphans  #-}

{-# LANGUAGE Arrows                 #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TemplateHaskell        #-}

module Gargantext.Database.Schema.ContextNodeNgrams
  where

import Prelude
import Gargantext.Database.Schema.Prelude
import Gargantext.Database.Schema.Ngrams (NgramsTypeId, NgramsId)
import Gargantext.Database.Admin.Types.Node



type ContextNodeNgrams =
  ContextNodeNgramsPoly ContextId ListId NgramsId NgramsTypeId Double


data ContextNodeNgramsPoly c n ngrams_id ngt w
   = ContextNodeNgrams { _cnng_context_id   :: !c
                       , _cnng_node_id      :: !n
                       , _cnng_ngrams_id    :: !ngrams_id
                       , _cnng_ngramsType   :: !ngt
                       , _cnng_weight       :: !w
                       } deriving (Show)

type ContextNodeNgramsWrite =
     ContextNodeNgramsPoly (Column SqlInt4  )
                           (Column SqlInt4  )
                           (Column SqlInt4  )
                           (Column SqlInt4  )
                           (Column SqlFloat8)

type ContextNodeNgramsRead  =
     ContextNodeNgramsPoly (Column SqlInt4  )
                           (Column SqlInt4  )
                           (Column SqlInt4  )
                           (Column SqlInt4  )
                           (Column SqlFloat8)

type ContextNodeNgramsReadNull =
     ContextNodeNgramsPoly (Column (Nullable SqlInt4  ))
                           (Column (Nullable SqlInt4  ))
                           (Column (Nullable SqlInt4  ))
                           (Column (Nullable SqlInt4  ))
                           (Column (Nullable SqlFloat8))

$(makeAdaptorAndInstance "pContextNodeNgrams" ''ContextNodeNgramsPoly)
makeLenses ''ContextNodeNgramsPoly


contextNodeNgramsTable :: Table ContextNodeNgramsWrite ContextNodeNgramsRead
contextNodeNgramsTable  = Table "context_node_ngrams"
                          ( pContextNodeNgrams ContextNodeNgrams
                               { _cnng_context_id = requiredTableField "context_id"
                               , _cnng_node_id    = requiredTableField "node_id"
                               , _cnng_ngrams_id  = requiredTableField "ngrams_id"
                               , _cnng_ngramsType = requiredTableField "ngrams_type"
                               , _cnng_weight     = requiredTableField "weight"
                               }
                          )