]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/Scores.hs
Fix present-but-empty vleague parsing in jfilexml.
[dead/htsn-import.git] / src / TSN / XML / Scores.hs
index f0ce6dea8373a18a3cd5cfeaf2b8f522924889e6..f7a03a61bac53376b69055258739cf333a0739db 100644 (file)
@@ -32,11 +32,9 @@ import Database.Groundhog (
   countAll,
   deleteAll,
   insert_,
-  migrate,
-  runMigration,
-  silentMigrationLogger )
+  migrate )
 import Database.Groundhog.Core ( DefaultKey )
-import Database.Groundhog.Generic ( runDbConn )
+import Database.Groundhog.Generic ( runDbConn, runMigrationSilent )
 import Database.Groundhog.Sqlite ( withSqliteConn )
 import Database.Groundhog.TH (
   groundhog,
@@ -59,11 +57,12 @@ import Text.XML.HXT.Core (
   xpWrap )
 
 -- Local imports.
+import Misc ( double_just )
 import TSN.Codegen ( tsn_codegen_config )
 import TSN.Database ( insert_or_select )
 import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
 import TSN.Location ( Location(..), pickle_location )
-import TSN.Picklers ( xp_time_stamp )
+import TSN.Picklers ( xp_attr_option, xp_time_stamp )
 import TSN.Team (
   FromXmlFkTeams(..),
   HTeam(..),
@@ -446,17 +445,13 @@ pickle_status :: PU ScoreGameStatus
 pickle_status =
   xpElem "status" $
     xpWrap (from_tuple, to_tuple') $
-      xpTriple (xpAttr "numeral" $ xpOption xpInt)
+      xpTriple (xpAttr "numeral" xp_attr_option)
                (xpOption $ xpAttr "type" $ xpOption xpText)
                xpText
   where
     from_tuple (x,y,z) = ScoreGameStatus x (join y) z
     to_tuple' ScoreGameStatus{..} =
-      (db_status_numeral, s, db_status_text)
-      where
-        s = case db_status_type of
-              Nothing -> Nothing
-              Just _  -> Just db_status_type
+      (db_status_numeral, double_just db_status_type, db_status_text)
 
 
 -- | Convert a 'ScoreGameXml' to/from \<game\>.
@@ -524,8 +519,7 @@ pickle_hteam =
                (xpOption xpText) -- Team name
   where
     from_tuple (x,y,z)= HTeamXml (HTeam (Team x Nothing z)) (join y)
-    to_tuple' (HTeamXml (HTeam t) Nothing) = (team_id t, Nothing, name t)
-    to_tuple' (HTeamXml (HTeam t) jhp) = (team_id t, Just jhp, name t)
+    to_tuple' (HTeamXml (HTeam t) jhp) = (team_id t, double_just jhp, name t)
 
 
 
@@ -629,7 +623,7 @@ test_on_delete_cascade = testGroup "cascading delete tests"
       let d = undefined :: ScoreGame
       let e = undefined :: Score_Location
       actual <- withSqliteConn ":memory:" $ runDbConn $ do
-                  runMigration silentMigrationLogger $ do
+                  runMigrationSilent $ do
                     migrate a
                     migrate b
                     migrate c