Compare commits

..

No commits in common. "64736a801190b52bc0709b4ecbc6da85a83b95e9" and "7c7c6df955b8649ae0c4e8a3aea0d58dd2ea0f60" have entirely different histories.

2 changed files with 9 additions and 10 deletions

View File

@ -45,6 +45,8 @@ 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)
@ -550,7 +552,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 :: [ Posts.Post ] = fst $ foldl' foldFn ([], local_idx) to_insert_list let insert_posts = 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) ✓
@ -575,14 +577,11 @@ 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 foldFn :: ([Posts.Post], Map.Map Int64 Int) -> (Threads.Thread, JSONPosts.Post, Client.PostId) -> ([Posts.Post], Map.Map Int64 Int)
:: ([Posts.Post], Map.Map Int64 Int) foldFn (posts, idx_map) (t, p, c) = trace "foldFn" $
-> (Threads.Thread, JSONPosts.Post, Client.PostId) case Map.lookup thread_id (trace ("map size: " ++ (show $ length idx_map)) idx_map) of
-> ([Posts.Post], Map.Map Int64 Int) Nothing -> (traceShowId (post 1) : posts, trace ("inserting_1 " ++ show thread_id ++ ": 1")$ Map.insert thread_id 1 idx_map)
foldFn (posts, idx_map) (t, p, c) = Just i -> (traceShowId (post (i + 1)) : posts, trace ("inserting_2 " ++ show thread_id ++ ": " ++ show (i + 1)) $ Map.insert thread_id (i + 1) idx_map)
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 cff3dd9e9fd013a0eedaa17df52e8f9eb5ef73c6 Subproject commit ffe952e22939b21f8576d79752c863a95c208e1e