Last active
November 27, 2017 00:11
-
-
Save AlistairB/a7fdc2ccfd01d5955e25950fc656fe30 to your computer and use it in GitHub Desktop.
Xml Error Refactor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- a huge number of imports above | |
main :: IO () | |
main = do | |
createDirectoryIfMissing True "output" | |
env <- getAppEnv | |
let connInfo = dbConnectInfo env | |
db <- dbConnection connInfo | |
queryText <- BS.readFile "db/errors.sql" | |
results <- query_ db (Query queryText) | |
date <- getCurrentTime | |
timeZone <- getCurrentTimeZone | |
let outputs = massageAll date timeZone results | |
let csvOutput = toCSV outputs | |
writeFile "output/results.csv" csvOutput | |
liftIO $ ftpFile env csvOutput | |
email (Email (emailFromAddress env) (emailCCAddresses env) (emailToAddresses env) "XML Error Notifications") "output/results.csv" | |
print $ "Outputed " ++ show (length outputs) ++ " rows" | |
-- lots more code below |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main :: IO () | |
main = do | |
config <- getAppConfig | |
filename' <- filename | |
results <- fetchResults config | |
transformed <- transform results | |
let outputPath = "output/" ++ filename' | |
encoded = encode transformed | |
createDirectoryIfMissing True "output" | |
writeFile outputPath encoded | |
ftp config outputPath | |
email config outputPath | |
print $ "Outputed " ++ show (length transformed) ++ " rows for file " ++ filename' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment