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
159
Issues
159
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
05f41f58
Commit
05f41f58
authored
Dec 11, 2024
by
Grégoire Locqueville
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed some more dead code
parent
082be2c7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
148 deletions
+1
-148
EKG.hs
src/Gargantext/API/EKG.hs
+0
-31
Node.hs
src/Gargantext/API/GraphQL/Node.hs
+1
-12
Job.hs
src/Gargantext/API/Job.hs
+0
-4
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+0
-101
No files found.
src/Gargantext/API/EKG.hs
View file @
05f41f58
...
@@ -16,16 +16,8 @@ Portability : POSIX
...
@@ -16,16 +16,8 @@ Portability : POSIX
module
Gargantext.API.EKG
where
module
Gargantext.API.EKG
where
import
Data.HashMap.Strict
as
HM
import
Data.Text
as
T
import
Data.Text
as
T
import
Data.Text.IO
as
T
import
Data.Time.Clock.POSIX
(
getPOSIXTime
)
import
Network.Wai
(
Middleware
)
import
Protolude
import
Servant
import
Servant
import
Servant.Auth
(
Auth
)
import
Servant.Ekg
(
HasEndpoint
,
getEndpoint
,
enumerateEndpoints
,
monitorEndpoints
)
import
System.Metrics
import
System.Metrics.Json
qualified
as
J
import
System.Metrics.Json
qualified
as
J
-- Mimics https://github.com/tibbe/ekg/blob/master/System/Remote/Snap.hs#L98
-- Mimics https://github.com/tibbe/ekg/blob/master/System/Remote/Snap.hs#L98
...
@@ -37,26 +29,3 @@ type EkgAPI =
...
@@ -37,26 +29,3 @@ type EkgAPI =
)
:<|>
)
:<|>
Raw
Raw
)
)
ekgServer
::
FilePath
->
Store
->
Server
EkgAPI
ekgServer
assetsDir
store
=
(
getAll
:<|>
getOne
)
:<|>
serveDirectoryFileServer
assetsDir
where
getAll
=
J
.
Sample
<$>
liftIO
(
sampleAll
store
)
getOne
segments
=
do
let
metric
=
T
.
intercalate
"."
segments
metrics
<-
liftIO
(
sampleAll
store
)
maybe
(
liftIO
(
T
.
putStrLn
"not found boohoo"
)
>>
throwError
err404
)
(
return
.
J
.
Value
)
(
HM
.
lookup
metric
metrics
)
newEkgStore
::
HasEndpoint
api
=>
Proxy
api
->
IO
(
Store
,
Middleware
)
newEkgStore
api
=
do
s
<-
newStore
registerGcMetrics
s
registerCounter
"ekg.server_timestamp_ms"
getTimeMs
s
-- used by UI
mid
<-
monitorEndpoints
api
s
pure
(
s
,
mid
)
where
getTimeMs
=
(
round
.
(
*
1000
))
`
fmap
`
getPOSIXTime
instance
HasEndpoint
api
=>
HasEndpoint
(
Auth
xs
a
:>
api
)
where
getEndpoint
_
=
getEndpoint
(
Proxy
::
Proxy
api
)
enumerateEndpoints
_
=
enumerateEndpoints
(
Proxy
::
Proxy
api
)
src/Gargantext/API/GraphQL/Node.hs
View file @
05f41f58
...
@@ -14,8 +14,7 @@ Portability : POSIX
...
@@ -14,8 +14,7 @@ Portability : POSIX
module
Gargantext.API.GraphQL.Node
where
module
Gargantext.API.GraphQL.Node
where
import
Data.Aeson
(
Result
(
..
),
Value
(
..
)
)
import
Data.Aeson
(
Value
(
..
)
)
import
Data.Aeson.KeyMap
qualified
as
KM
import
Data.Morpheus.Types
(
GQLType
)
import
Data.Morpheus.Types
(
GQLType
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Auth.PolicyCheck
(
nodeReadChecks
,
AccessPolicyManager
)
import
Gargantext.API.Auth.PolicyCheck
(
nodeReadChecks
,
AccessPolicyManager
)
...
@@ -28,7 +27,6 @@ import Gargantext.Database.Prelude (IsDBEnvExtra) -- , JSONB)
...
@@ -28,7 +27,6 @@ import Gargantext.Database.Prelude (IsDBEnvExtra) -- , JSONB)
import
Gargantext.Database.Query.Table.Node
(
getClosestChildrenByType
,
getClosestParentIdByType
,
getNode
)
import
Gargantext.Database.Query.Table.Node
(
getClosestChildrenByType
,
getClosestParentIdByType
,
getNode
)
import
Gargantext.Database.Schema.Node
qualified
as
N
import
Gargantext.Database.Schema.Node
qualified
as
N
import
Gargantext.Prelude
import
Gargantext.Prelude
import
PUBMED.Types
qualified
as
PUBMED
data
Corpus
=
Corpus
data
Corpus
=
Corpus
{
id
::
Int
{
id
::
Int
...
@@ -145,12 +143,3 @@ toCorpus N.Node { .. } = Corpus { id = NN.unNodeId _node_id
...
@@ -145,12 +143,3 @@ toCorpus N.Node { .. } = Corpus { id = NN.unNodeId _node_id
,
name
=
_node_name
,
name
=
_node_name
,
parent_id
=
NN
.
unNodeId
<$>
_node_parent_id
,
parent_id
=
NN
.
unNodeId
<$>
_node_parent_id
,
type_id
=
_node_typename
}
,
type_id
=
_node_typename
}
pubmedAPIKeyFromValue
::
Value
->
Maybe
PUBMED
.
APIKey
pubmedAPIKeyFromValue
(
Object
kv
)
=
case
KM
.
lookup
"pubmed_api_key"
kv
of
Nothing
->
Nothing
Just
v
->
case
fromJSON
v
of
Error
_
->
Nothing
Success
v'
->
Just
v'
pubmedAPIKeyFromValue
_
=
Nothing
src/Gargantext/API/Job.hs
View file @
05f41f58
...
@@ -16,7 +16,6 @@ module Gargantext.API.Job (
...
@@ -16,7 +16,6 @@ module Gargantext.API.Job (
,
jobLogAddMore
,
jobLogAddMore
,
jobLogFailures
,
jobLogFailures
,
jobLogFailTotal
,
jobLogFailTotal
,
jobLogEvt
,
jobLogFailTotalWithMessage
,
jobLogFailTotalWithMessage
,
RemainingSteps
(
..
)
,
RemainingSteps
(
..
)
,
addErrorEvent
,
addErrorEvent
...
@@ -84,6 +83,3 @@ jobLogFailTotal (JobLog { _scst_succeeded = mSucc
...
@@ -84,6 +83,3 @@ jobLogFailTotal (JobLog { _scst_succeeded = mSucc
jobLogFailTotalWithMessage
::
ToHumanFriendlyError
e
=>
e
->
JobLog
->
JobLog
jobLogFailTotalWithMessage
::
ToHumanFriendlyError
e
=>
e
->
JobLog
->
JobLog
jobLogFailTotalWithMessage
message
jl
=
addErrorEvent
message
$
jobLogFailTotal
jl
jobLogFailTotalWithMessage
message
jl
=
addErrorEvent
message
$
jobLogFailTotal
jl
jobLogEvt
::
JobLog
->
ScraperEvent
->
JobLog
jobLogEvt
jl
evt
=
over
(
scst_events
.
_Just
)
(
\
evts
->
(
evt
:
evts
))
jl
src/Gargantext/API/Ngrams.hs
View file @
05f41f58
...
@@ -105,53 +105,6 @@ import Text.Collate qualified as Unicode
...
@@ -105,53 +105,6 @@ import Text.Collate qualified as Unicode
{-
-- TODO sequences of modifications (Patchs)
type NgramsIdPatch = Patch NgramsId NgramsPatch
ngramsPatch :: Int -> NgramsPatch
ngramsPatch n = NgramsPatch (DM.fromList [(1, StopTerm)]) (Set.fromList [n]) Set.empty
toEdit :: NgramsId -> NgramsPatch -> Edit NgramsId NgramsPatch
toEdit n p = Edit n p
ngramsIdPatch :: Patch NgramsId NgramsPatch
ngramsIdPatch = fromList $ catMaybes $ reverse [ replace (1::NgramsId) (Just $ ngramsPatch 1) Nothing
, replace (1::NgramsId) Nothing (Just $ ngramsPatch 2)
, replace (2::NgramsId) Nothing (Just $ ngramsPatch 2)
]
-- applyPatchBack :: Patch -> IO Patch
-- isEmptyPatch = Map.all (\x -> Set.isEmpty (add_children x) && Set.isEmpty ... )
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
{-
-- TODO: Replace.old is ignored which means that if the current list
-- `MapTerm` and that the patch is `Replace CandidateTerm StopTerm` then
-- the list is going to be `StopTerm` while it should keep `MapTerm`.
-- However this should not happen in non conflicting situations.
mkListsUpdate :: NgramsType -> NgramsTablePatch -> [(NgramsTypeId, NgramsTerm, ListTypeId)]
mkListsUpdate nt patches =
[ (ngramsTypeId nt, ng, listTypeId lt)
| (ng, patch) <- patches ^.. ntp_ngrams_patches . ifolded . withIndex
, lt <- patch ^.. patch_list . new
]
mkChildrenGroups :: (PatchSet NgramsTerm -> Set NgramsTerm)
-> NgramsType
-> NgramsTablePatch
-> [(NgramsTypeId, NgramsParent, NgramsChild)]
mkChildrenGroups addOrRem nt patches =
[ (ngramsTypeId nt, parent, child)
| (parent, patch) <- patches ^.. ntp_ngrams_patches . ifolded . withIndex
, child <- patch ^.. patch_children . to addOrRem . folded
]
-}
------------------------------------------------------------------------
saveNodeStory
::
(
MonadReader
env
m
,
MonadBase
IO
m
,
HasNodeStoryImmediateSaver
env
)
saveNodeStory
::
(
MonadReader
env
m
,
MonadBase
IO
m
,
HasNodeStoryImmediateSaver
env
)
=>
NodeId
->
ArchiveList
->
m
()
=>
NodeId
->
ArchiveList
->
m
()
saveNodeStory
nId
a
=
do
saveNodeStory
nId
a
=
do
...
@@ -183,34 +136,6 @@ insertNewOnly :: a -> Maybe b -> a
...
@@ -183,34 +136,6 @@ insertNewOnly :: a -> Maybe b -> a
insertNewOnly
m
=
maybe
m
(
const
$
errorTrace
"insertNewOnly: impossible"
)
insertNewOnly
m
=
maybe
m
(
const
$
errorTrace
"insertNewOnly: impossible"
)
-- TODO error handling
-- TODO error handling
{- unused
-- TODO refactor with putListNgrams
copyListNgrams :: RepoCmdM env err m
=> NodeId -> NodeId -> NgramsType
-> m ()
copyListNgrams srcListId dstListId ngramsType = do
var <- view repoVar
liftBase $ modifyMVar_ var $
pure . (r_state . at ngramsType %~ (Just . f . something))
saveNodeStory
where
f :: Map NodeId NgramsTableMap -> Map NodeId NgramsTableMap
f m = m & at dstListId %~ insertNewOnly (m ^. at srcListId)
-- TODO refactor with putListNgrams
-- The list must be non-empty!
-- The added ngrams must be non-existent!
addListNgrams :: RepoCmdM env err m
=> NodeId -> NgramsType
-> [NgramsElement] -> m ()
addListNgrams listId ngramsType nes = do
var <- view repoVar
liftBase $ modifyMVar_ var $
pure . (r_state . at ngramsType . _Just . at listId . _Just <>~ m)
saveNodeStory
where
m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes
-}
-- | TODO: incr the Version number
-- | TODO: incr the Version number
-- && should use patch
-- && should use patch
...
@@ -227,18 +152,6 @@ setListNgrams listId ngramsType ns = do
...
@@ -227,18 +152,6 @@ setListNgrams listId ngramsType ns = do
Nothing
->
Just
ns
Nothing
->
Just
ns
Just
ns'
->
Just
$
ns
<>
ns'
)
Just
ns'
->
Just
$
ns
<>
ns'
)
saveNodeStory
listId
a'
saveNodeStory
listId
a'
-- liftBase $ atomically $ do
-- nls <- readTVar var
-- writeTVar var $
-- ( unNodeStory
-- . at listId . _Just
-- . a_state
-- . at ngramsType
-- %~ (\mns' -> case mns' of
-- Nothing -> Just ns
-- Just ns' -> Just $ ns <> ns')
-- ) nls
-- saveNodeStory
newNgramsFromNgramsStatePatch
::
NgramsStatePatch'
->
[
Ngrams
]
newNgramsFromNgramsStatePatch
::
NgramsStatePatch'
->
[
Ngrams
]
...
@@ -260,24 +173,10 @@ commitStatePatch :: ( HasNodeStory env err m
...
@@ -260,24 +173,10 @@ commitStatePatch :: ( HasNodeStory env err m
->
Versioned
NgramsStatePatch'
->
Versioned
NgramsStatePatch'
->
m
(
Versioned
NgramsStatePatch'
)
->
m
(
Versioned
NgramsStatePatch'
)
commitStatePatch
listId
(
Versioned
_p_version
p
)
=
do
commitStatePatch
listId
(
Versioned
_p_version
p
)
=
do
-- printDebug "[commitStatePatch]" listId
a
<-
getNodeStory
listId
a
<-
getNodeStory
listId
archiveSaver
<-
view
hasNodeArchiveStoryImmediateSaver
archiveSaver
<-
view
hasNodeArchiveStoryImmediateSaver
-- ns <- liftBase $ atomically $ readTVar var
let
let
-- a = ns ^. unNodeStory . at listId . non initArchive
-- apply patches from version p_version to a ^. a_version
-- TODO Check this
--q = mconcat $ take (a ^. a_version - p_version) (a ^. a_history)
q
=
mconcat
$
a
^.
a_history
q
=
mconcat
$
a
^.
a_history
--printDebug "[commitStatePatch] transformWith" (p,q)
-- let tws s = case s of
-- (Mod p) -> "Mod"
-- _ -> "Rpl"
-- printDebug "[commitStatePatch] transformWith" (tws $ p ^. _NgramsPatch, tws $ q ^. _NgramsPatch)
let
(
p'
,
q'
)
=
transformWith
ngramsStatePatchConflictResolution
p
q
(
p'
,
q'
)
=
transformWith
ngramsStatePatchConflictResolution
p
q
a'
=
a
&
a_version
+~
1
a'
=
a
&
a_version
+~
1
&
a_state
%~
act
p'
&
a_state
%~
act
p'
...
...
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