Commit 5a4f2c79 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

WIP: fix #313 regressed ngrams grouping

It turns out that we don't need to call `pruneForest` inside
`searchtableNgrams`. After all, we are just displaying information that
should be correct in the database from the get-go, so why we would need
any of that?

It turns out that the fix for #313 to support duplicated ngrams during
importing broke hierarchical grouping.

I have just temporarily commented out the code and I need to find a fix,
better also writing a test to ensure that grouping will still work in the
future.
parent 66198af7
Pipeline #7749 failed with stages
in 46 minutes and 7 seconds
......@@ -510,7 +510,7 @@ searchTableNgrams :: Versioned (Map NgramsTerm NgramsElement)
searchTableNgrams versionedTableMap NgramsSearchQuery{..} =
let tableMap = versionedTableMap ^. v_data
filteredData = filterNgramsNodes _nsq_listType _nsq_minSize _nsq_maxSize _nsq_searchQuery tableMap
forestRoots = Set.fromList . Map.elems . destroyForest . pruneForest . buildForest $ filteredData
forestRoots = Set.fromList . Map.elems . destroyForest . buildForest $ filteredData
tableMapSorted = versionedTableMap
& v_data .~ (NgramsTable . sortAndPaginate . withInners tableMap $ forestRoots)
......
......@@ -216,8 +216,8 @@ nodeStoryInc ns@(NodeStory nls) nId = do
-- `nre_parent` and `nre_children`. We want to make sure that all
-- children entries (i.e. ones that have `nre_parent`) have the same
-- `list` as their parent entry.
fixChildrenInNgrams :: NgramsState' -> NgramsState'
fixChildrenInNgrams ns = archiveStateFromList $ nsParents <> nsChildrenFixed
_fixChildrenInNgrams :: NgramsState' -> NgramsState'
_fixChildrenInNgrams ns = archiveStateFromList $ nsParents <> nsChildrenFixed
where
(nsParents, nsChildren) = getParentsChildren ns
parentNtMap = Map.fromList $ (\(_nt, t, nre) -> (t, nre ^. nre_list)) <$> nsParents
......@@ -233,8 +233,8 @@ fixChildrenInNgrams ns = archiveStateFromList $ nsParents <> nsChildrenFixed
-- | (#281) Sometimes, when we upload a new list, a child can be left
-- without a parent. Find such ngrams and set their 'root' and
-- 'parent' to 'Nothing'.
fixChildrenWithNoParent :: NgramsState' -> NgramsState'
fixChildrenWithNoParent ns = archiveStateFromList $ nsParents <> nsChildrenFixed
_fixChildrenWithNoParent :: NgramsState' -> NgramsState'
_fixChildrenWithNoParent ns = archiveStateFromList $ nsParents <> nsChildrenFixed
where
(nsParents, nsChildren) = getParentsChildren ns
parentNtMap = Map.fromList $ (\(_nt, t, nre) -> (t, nre ^. nre_children & mSetToSet)) <$> nsParents
......@@ -296,11 +296,7 @@ mkNodeStoryEnv = do
-- |NOTE Fixing a_state is kinda a hack. We shouldn't land
-- |with bad state in the first place.
upsertNodeStories nId $
a & a_state %~ (
fixChildrenDuplicatedAsParents
. fixChildrenInNgrams
. fixChildrenWithNoParent
)
a & a_state %~ identity
let archive_saver_immediate nId a = do
insertNodeArchiveHistory nId (a ^. a_version) $ reverse $ a ^. a_history
pure $ a & a_history .~ []
......
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