diff options
author | "Vincent Ambo ext:(%22) <tazjin@gmail.com> | 2013-04-28T11·12+0200 |
---|---|---|
committer | "Vincent Ambo ext:(%22) <tazjin@gmail.com> | 2013-04-28T11·12+0200 |
commit | 247265f35499d82706fb99ac0a68c90cc169ca1a (patch) | |
tree | 08162c6a14aa354d199f133f807eb7b48e2c9fb5 | |
parent | b3fb7f0f341bf3574a5c42fbbf3e0ddc3ea286a1 (diff) |
* saved the function that I cleaned the comments with. The function is horrendous
-rw-r--r-- | tools/fixcomments.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/fixcomments.hs b/tools/fixcomments.hs new file mode 100644 index 000000000000..dc89dbdd647f --- /dev/null +++ b/tools/fixcomments.hs @@ -0,0 +1,21 @@ + +fixComments :: AcidState Blog -> IO () +fixComments acid = do + entriesDE <- query' acid $ LatestEntries DE + entriesEN <- query' acid $ LatestEntries EN + filterComments entriesDE + filterComments entriesEN + where + (cDate :: UTCTime) = fromJust $ parseTime defaultTimeLocale "%d.%m.%Y %T" "22.04.2012 21:57:35" + foldOp :: [(EntryId, [UTCTime])] -> Entry -> [(EntryId, [UTCTime])] + foldOp l e = let c = map cdate $ filter (\c1 -> cdate c1 > cDate) $ comments e + in if null c then l + else (entryId e, c) : l + pred :: Entry -> Bool + pred e = let f eId [] = False + f eId (c:r) = if (cdate c > cDate) then True + else f eId r + in f (entryId e) (comments e) + filterComments entries = mapM_ removeComments $ foldl foldOp [] $ filter pred entries + removeComments :: (EntryId, [UTCTime]) -> IO () + removeComments (eId, comments) = mapM_ (\c -> update' acid $ DeleteComment eId c) comments \ No newline at end of file |