X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FSportInfo.hs;h=5db69b9a9bebda17d83ece05c6c8de67881f3dcf;hb=32147474ba5c91452eeb532381f63e88c257a982;hp=187796c34b3c571fa5fd66a42c2d1e29be9abb98;hpb=a6e096bbac16cc51dbf2d5417e90b7efd03a3b7d;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/SportInfo.hs b/src/TSN/XML/SportInfo.hs index 187796c..5db69b9 100644 --- a/src/TSN/XML/SportInfo.hs +++ b/src/TSN/XML/SportInfo.hs @@ -30,10 +30,8 @@ import Data.Time.Clock ( UTCTime ) import Database.Groundhog ( countAll, insert_, - migrate, - runMigration, - silentMigrationLogger ) -import Database.Groundhog.Generic ( runDbConn ) + migrate ) +import Database.Groundhog.Generic ( runDbConn, runMigrationSilent ) import Database.Groundhog.Sqlite ( withSqliteConn ) import Database.Groundhog.TH ( defaultCodegenConfig, @@ -50,6 +48,7 @@ import TSN.DbImport ( ImportResult(..), run_dbmigrate ) import TSN.Parse ( + ParseError, parse_message, parse_xmlfid, parse_xml_time_stamp ) @@ -72,11 +71,16 @@ dtds = "CBASK_FGPctXML.dtd", "CBASK_FoulsXML.dtd", "CBASK_FTPctXML.dtd", + "Cbask_Indv_No_Avg_XML.dtd", "Cbask_Indv_Scoring_XML.dtd", + "Cbask_Indv_Shooting_XML.dtd", "CBASK_MinutesXML.dtd", "Cbask_Polls_XML.dtd", "CBASK_ReboundsXML.dtd", "CBASK_ScoringLeadersXML.dtd", + "Cbask_Team_Scoring_Rebound_Margin_XML.dtd", + "Cbask_Team_Scoring_XML.dtd", + "Cbask_Team_Shooting_Pct_XML.dtd", "Cbask_Team_ThreePT_Made_XML.dtd", "Cbask_Team_ThreePT_PCT_XML.dtd", "Cbask_Team_Win_Pct_XML.dtd", @@ -161,19 +165,29 @@ dtds = "NCAA_Conference_Schedule_XML.dtd", "nflfirstdownxml.dtd", "NFLFumbleLeaderXML.dtd", + "NFLGrassTurfDomeOutsideXML.dtd", "NFLGiveTakeXML.dtd", "NFLInside20XML.dtd", + "NFLInterceptionLeadersXML.dtd", "NFLKickoffsXML.dtd", "NFLMondayNightXML.dtd", + "NFLPassingLeadersXML.dtd", "NFLPassLeadXML.dtd", "NFLQBStartsXML.dtd", + "NFLReceivingLeadersXML.dtd", + "NFLRushingLeadersXML.dtd", "NFLSackLeadersXML.dtd", "nflstandxml.dtd", + "NFLTackleFFLeadersXML.dtd", "NFLTeamRankingsXML.dtd", + "NFLTopKickoffReturnXML.dtd", "NFLTopPerformanceXML.dtd", + "NFLTopPuntReturnXML.dtd", "NFLTotalYardageXML.dtd", + "NFLYardsXML.dtd", "NFL_KickingLeaders_XML.dtd", "NFL_NBA_Draft_XML.dtd", + "NFL_PuntingLeaders_XML.dtd", "NFL_Roster_XML.dtd", "NFL_Team_Stats_XML.dtd", "Transactions_XML.dtd", @@ -208,12 +222,12 @@ data SportInfo = -- | Attempt to parse a 'SportInfo' from an 'XmlTree'. If we cannot, -- we fail with an error message. -- -parse_xml :: String -> XmlTree -> Either String SportInfo +parse_xml :: String -> XmlTree -> Either ParseError SportInfo parse_xml dtdname xmltree = do xmlfid <- parse_xmlfid xmltree timestamp <- parse_xml_time_stamp xmltree message <- parse_message xmltree - return $ SportInfo dtdname (fromInteger xmlfid) timestamp (xshow [message]) + return $ SportInfo dtdname xmlfid timestamp (xshow [message]) -- @@ -275,7 +289,7 @@ test_accessors = testCase "we can access a parsed sport_info" $ do let a2 = xml_file_id t let ex2 = 2011 let a3 = show $ time_stamp t - let ex3 = "2009-09-28 00:50:00 UTC" + let ex3 = "2009-09-27 19:50:00 UTC" let a4 = take 9 (xml t) let ex4 = "" let actual = (a1,a2,a3,a4) @@ -319,7 +333,7 @@ test_dbimport_succeeds = testCase "dbimport succeeds" $ do xmltrees <- mapM unsafe_read_document sport_info_test_files let msgs = rights $ map (parse_xml "dummy") xmltrees actual <- withSqliteConn ":memory:" $ runDbConn $ do - runMigration silentMigrationLogger $ + runMigrationSilent $ migrate (undefined :: SportInfo) mapM_ dbimport msgs countAll (undefined :: SportInfo)