Commits

Luke Plant committed 99479b9

Fixed migration script for the case of posts with empty body and a completed summary

  • Participants
  • Parent commits 38d2fc5

Comments (0)

Files changed (1)

 
 readPosts = makeItems "posts.txt" mkPost
             >>= mapM addFullText
+            >>= mapM (return . fixEmptyFullTexts)
             >>= return . sortBy (comparing P.timestamp)
     where mkPost row = P.Post { P.uid = read (row !! 0)
                               , P.title = row !! 1
                              let fixed = fixCodes f
                              return p { P.post_raw = fixed,
                                         P.post_formatted = fixed }
+          fixEmptyFullTexts p = if null $ P.post_raw p
+                                then p { P.post_raw = P.summary_raw p
+                                       , P.post_formatted = P.summary_formatted p
+                                       }
+                                else p
           -- Fix dodgy stuff, and reinterpret as UTF8
           fixCodes txt = UTF8.toString $ regexReplace (BL.pack "
") (BL.pack "\n") (BL.pack txt)