X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FJFile.hs;h=51e845d9b6afe69a9b4ba8d1a7d606b19c17041a;hb=3a8d465bcc6f36b6e7601cf1902e575171aa7beb;hp=51db0abfa32af3b0be591e1099803a5289b4b853;hpb=d88388235ec3df702f80e70d50898850befef6ed;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/JFile.hs b/src/TSN/XML/JFile.hs index 51db0ab..51e845d 100644 --- a/src/TSN/XML/JFile.hs +++ b/src/TSN/XML/JFile.hs @@ -70,14 +70,17 @@ import TSN.Picklers ( xp_time, xp_time_dots, xp_time_stamp ) -import TSN.Team ( Team(..) ) +import TSN.Team ( + FromXmlFkTeams(..), + HTeam(..), + Team(..), + VTeam(..) ) import TSN.XmlImport ( XmlImport(..), XmlImportFkTeams(..) ) import Xml ( Child(..), FromXml(..), - FromXmlFkTeams(..), ToDb(..), pickle_unpickle, unpickleable, @@ -234,9 +237,9 @@ data JFileGameXml = xml_season_type :: Maybe String, xml_game_date :: UTCTime, xml_game_time :: UTCTime, - xml_vteam :: Team, + xml_vteam :: VTeam, xml_vleague :: Maybe String, - xml_hteam :: Team, + xml_hteam :: HTeam, xml_hleague :: Maybe String, xml_vscore :: Int, xml_hscore :: Int, @@ -325,8 +328,8 @@ instance DbImport Message where -- Now loop through the message's games forM_ (xml_games $ xml_gamelist m) $ \game -> do -- First we insert the home and away teams. - away_team_id <- insert_or_select (xml_vteam game) - home_team_id <- insert_or_select (xml_hteam game) + away_team_id <- insert_or_select (vteam $ xml_vteam game) + home_team_id <- insert_or_select (hteam $ xml_hteam game) -- Now insert the game keyed to the "jfile" and its teams. insert_xml_fk_teams_ msg_id away_team_id home_team_id game @@ -353,8 +356,8 @@ mkPersist tsn_codegen_config [groundhog| - name: db_status dbName: status -# Many of the JFileGameOddsInfo fields are redundant and have -# been left out. + # Many of the JFileGameOddsInfo fields are redundant and have + # been left out. - embedded: JFileGameOddsInfo fields: - name: db_list_date @@ -541,7 +544,7 @@ pickle_odds_info = -- | (Un)pickle a home team to/from the dual XML/DB representation -- 'Team'. -- -pickle_home_team :: PU Team +pickle_home_team :: PU HTeam pickle_home_team = xpElem "hteam" $ xpWrap (from_tuple, to_tuple) $ @@ -549,16 +552,16 @@ pickle_home_team = (xpAttr "abbr" (xpOption xpText)) -- Some are blank (xpOption xpText) -- Yup, some are nameless where - from_tuple = uncurryN Team - to_tuple t = (team_id t, - abbreviation t, - name t) + from_tuple = HTeam . (uncurryN Team) + to_tuple (HTeam t) = (team_id t, + abbreviation t, + name t) -- | (Un)pickle an away team to/from the dual XML/DB representation -- 'Team'. -- -pickle_away_team :: PU Team +pickle_away_team :: PU VTeam pickle_away_team = xpElem "vteam" $ xpWrap (from_tuple, to_tuple) $ @@ -566,10 +569,10 @@ pickle_away_team = (xpAttr "abbr" (xpOption xpText)) -- Some are blank (xpOption xpText) -- Yup, some are nameless where - from_tuple = uncurryN Team - to_tuple t = (team_id t, - abbreviation t, - name t) + from_tuple = VTeam . (uncurryN Team) + to_tuple (VTeam t) = (team_id t, + abbreviation t, + name t) pickle_status :: PU JFileGameStatus