Commit 9b35cefd authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] more generic history of patch

parent 873d4038
...@@ -24,20 +24,20 @@ import Gargantext.Database.Schema.Ngrams (NgramsType(..)) ...@@ -24,20 +24,20 @@ import Gargantext.Database.Schema.Ngrams (NgramsType(..))
history :: Foldable t history :: (Foldable t, Foldable h)
=> NgramsType => t NgramsType
-> t ListId -> h ListId
-> Repo s NgramsStatePatch -> Repo s NgramsStatePatch
-> Map ListId [Map NgramsTerm NgramsPatch] -> Map NgramsType (Map ListId [Map NgramsTerm NgramsPatch])
history nt lists = Map.unionsWith (<>) history types lists = Map.unionsWith (<>)
. map (Map.map cons) . map (Map.map (Map.map cons))
. map (Map.filterWithKey (\k _ -> List.elem k lists)) . map (Map.map ((Map.filterWithKey (\k _ -> List.elem k lists))))
. catMaybes . map (Map.filterWithKey (\k _ -> List.elem k types))
. map (Map.lookup nt)
. map toMap . map toMap
. view r_history . view r_history
where where
cons a = a : [] cons a = [a]
toMap :: PatchMap NgramsType toMap :: PatchMap NgramsType
(PatchMap NodeId (PatchMap NodeId
...@@ -57,3 +57,4 @@ toMap = Map.map (Map.map unNgramsTablePatch) . (Map.map toMap') . toMap' ...@@ -57,3 +57,4 @@ toMap = Map.map (Map.map unNgramsTablePatch) . (Map.map toMap') . toMap'
unNgramsTablePatch :: NgramsTablePatch -> Map NgramsTerm NgramsPatch unNgramsTablePatch :: NgramsTablePatch -> Map NgramsTerm NgramsPatch
unNgramsTablePatch (NgramsTablePatch p) = toMap' p unNgramsTablePatch (NgramsTablePatch p) = toMap' p
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