Compare commits

...

2 Commits

Author SHA1 Message Date
towards-a-new-leftypol 64736a8011 Update common submodule 2024-03-22 19:45:00 -04:00
towards-a-new-leftypol ef7ba97d09 remove debug statements 2024-03-20 15:00:58 -04:00
2 changed files with 10 additions and 9 deletions

View File

@ -45,8 +45,6 @@ import qualified Common.PostsType as Posts
import qualified Hash as Hash import qualified Hash as Hash
import qualified Data.WordUtil as Words import qualified Data.WordUtil as Words
import Debug.Trace (trace, traceShowId)
newtype SettingsCLI = SettingsCLI newtype SettingsCLI = SettingsCLI
{ jsonFile :: FilePath { jsonFile :: FilePath
} deriving (Show, Data, Typeable) } deriving (Show, Data, Typeable)
@ -552,7 +550,7 @@ createNewPosts settings tuples = do
-- Map of thread_id to the largest local_idx value (which would be the number of the last post in the thread) -- Map of thread_id to the largest local_idx value (which would be the number of the last post in the thread)
let local_idx :: Map.Map Int64 Int = Map.fromList thread_max_local_idxs let local_idx :: Map.Map Int64 Int = Map.fromList thread_max_local_idxs
let insert_posts = fst $ foldl' foldFn ([], local_idx) to_insert_list let insert_posts :: [ Posts.Post ] = fst $ foldl' foldFn ([], local_idx) to_insert_list
-- posts to insert are the posts that are not in existing_posts -- posts to insert are the posts that are not in existing_posts
-- so we create a Set (thread_id, board_post_id) ✓ -- so we create a Set (thread_id, board_post_id) ✓
@ -577,11 +575,14 @@ createNewPosts settings tuples = do
newPosts :: [(Threads.Thread, JSONPosts.Post, Client.PostId)] -> Set (Int64, Int64) -> [(Threads.Thread, JSONPosts.Post, Client.PostId)] newPosts :: [(Threads.Thread, JSONPosts.Post, Client.PostId)] -> Set (Int64, Int64) -> [(Threads.Thread, JSONPosts.Post, Client.PostId)]
newPosts ts existing_set = filter (\(_, _, c) -> Set.notMember (Client.thread_id c, Client.board_post_id c) existing_set) ts newPosts ts existing_set = filter (\(_, _, c) -> Set.notMember (Client.thread_id c, Client.board_post_id c) existing_set) ts
foldFn :: ([Posts.Post], Map.Map Int64 Int) -> (Threads.Thread, JSONPosts.Post, Client.PostId) -> ([Posts.Post], Map.Map Int64 Int) foldFn
foldFn (posts, idx_map) (t, p, c) = trace "foldFn" $ :: ([Posts.Post], Map.Map Int64 Int)
case Map.lookup thread_id (trace ("map size: " ++ (show $ length idx_map)) idx_map) of -> (Threads.Thread, JSONPosts.Post, Client.PostId)
Nothing -> (traceShowId (post 1) : posts, trace ("inserting_1 " ++ show thread_id ++ ": 1")$ Map.insert thread_id 1 idx_map) -> ([Posts.Post], Map.Map Int64 Int)
Just i -> (traceShowId (post (i + 1)) : posts, trace ("inserting_2 " ++ show thread_id ++ ": " ++ show (i + 1)) $ Map.insert thread_id (i + 1) idx_map) foldFn (posts, idx_map) (t, p, c) =
case Map.lookup thread_id idx_map of
Nothing -> (post 1 : posts, Map.insert thread_id 1 idx_map)
Just i -> (post (i + 1) : posts, Map.insert thread_id (i + 1) idx_map)
where where
post :: Int -> Posts.Post post :: Int -> Posts.Post

@ -1 +1 @@
Subproject commit ffe952e22939b21f8576d79752c863a95c208e1e Subproject commit cff3dd9e9fd013a0eedaa17df52e8f9eb5ef73c6