]> gitweb.michael.orlitzky.com - dead/htsn-import.git/commitdiff
Remove redundant away team XML representation in ScheduleChanges.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 6 Jul 2014 01:16:01 +0000 (21:16 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 6 Jul 2014 01:16:01 +0000 (21:16 -0400)
src/TSN/XML/ScheduleChanges.hs

index 5f0eff25144b8c1c3b3ba8e7d0f2b522d3f6fb7e..5dc6872017b5ab2ca3af2480bce93ca488694815 100644 (file)
@@ -200,8 +200,8 @@ data ScheduleChangesListingXml =
     xml_game_date :: UTCTime,
     xml_game_time :: Maybe UTCTime,
     xml_location :: Maybe String,
-    xml_away_team :: ScheduleChangesListingAwayTeamXml,
-    xml_home_team :: ScheduleChangesListingHomeTeamXml,
+    xml_away_team :: ScheduleChangesListingTeamXml,
+    xml_home_team :: ScheduleChangesListingTeamXml,
     xml_vscore :: Int,
     xml_hscore :: Int,
     xml_listing_status :: ScheduleChangesListingStatus,
@@ -256,76 +256,42 @@ from_xml_fk_sport fk sport fk_away fk_home ScheduleChangesListingXml{..} =
 
 
 
--- * ScheduleChangesListingAwayTeamXml / ScheduleChangesListingHomeTeamXml
+-- * ScheduleChangesListingTeamXml
 
--- | The XML representation of a 'ScheduleChangesListing' away
+-- | The XML representation of a 'ScheduleChangesListing'
 --   team. Its corresponding database representation (along with that
 --   of the home team) is a "TSN.Team", but their XML representations
---   are different.
+--   are slightly different.
 --
-data ScheduleChangesListingAwayTeamXml =
-  ScheduleChangesListingAwayTeamXml {
-    away_team_id :: String,
-    away_team_name :: Maybe String }
+data ScheduleChangesListingTeamXml =
+  ScheduleChangesListingTeamXml {
+    xml_team_id :: String,
+    xml_team_name :: Maybe String }
   deriving (Eq, Show)
 
 
-instance ToDb ScheduleChangesListingAwayTeamXml where
-  -- | The database analogue of an 'ScheduleChangesListingAwayTeamXml' is
+instance ToDb ScheduleChangesListingTeamXml where
+  -- | The database analogue of an 'ScheduleChangesListingTeamXml' is
   --   a 'Team'.
   --
-  type Db ScheduleChangesListingAwayTeamXml = Team
+  type Db ScheduleChangesListingTeamXml = Team
 
 
-instance FromXml ScheduleChangesListingAwayTeamXml where
-  -- | To convert a 'ScheduleChangesListingAwayTeamXml' to a 'Team',
+instance FromXml ScheduleChangesListingTeamXml where
+  -- | To convert a 'ScheduleChangesListingTeamXml' to a 'Team',
   --   we set the non-existent abbreviation to \"Nothing\".
   --
-  from_xml ScheduleChangesListingAwayTeamXml{..} =
+  from_xml ScheduleChangesListingTeamXml{..} =
     Team {
-      team_id = away_team_id,
+      team_id = xml_team_id,
       abbreviation = Nothing,
-      name  = away_team_name }
+      name  = xml_team_name }
 
--- | Allow us to import ScheduleChangesListingAwayTeamXml directly.
+-- | Allow us to import ScheduleChangesListingTeamXml directly.
 --
-instance XmlImport ScheduleChangesListingAwayTeamXml
+instance XmlImport ScheduleChangesListingTeamXml
 
 
--- | The XML representation of a 'ScheduleChangesListing' home
---   team. Its corresponding database representation (along with that
---   of the away team) is a "TSN.Team", but their XML representations
---   are different.
---
-data ScheduleChangesListingHomeTeamXml =
-  ScheduleChangesListingHomeTeamXml {
-    home_team_id :: String,
-    home_team_name :: Maybe String }
-  deriving (Eq, Show)
-
-
-instance ToDb ScheduleChangesListingHomeTeamXml where
-  -- | The database analogue of an 'ScheduleChangesListingHomeTeamXml'
-  --   is a 'Team'.
-  --
-  type Db ScheduleChangesListingHomeTeamXml = Team
-
-
-instance FromXml ScheduleChangesListingHomeTeamXml where
-  -- | To convert a 'ScheduleChangesListingHomeTeamXml' to a 'Team',
-  --   we set the non-existent abbreviation to \"Nothing\".
-  --
-  from_xml ScheduleChangesListingHomeTeamXml{..} =
-    Team {
-      team_id = home_team_id,
-      abbreviation = Nothing,
-      name  = home_team_name }
-
-
--- | Allow us to import ScheduleChangesListingHomeTeamXml directly.
---
-instance XmlImport ScheduleChangesListingHomeTeamXml
-
 
 --
 -- * Database stuff.
@@ -413,30 +379,30 @@ mkPersist tsn_codegen_config [groundhog|
 
 -- | An (un)pickler for the \<Away_Team\> elements.
 --
-pickle_away_team :: PU ScheduleChangesListingAwayTeamXml
+pickle_away_team :: PU ScheduleChangesListingTeamXml
 pickle_away_team =
   xpElem "Away_Team" $
     xpWrap (from_tuple, to_tuple) $
     xpPair (xpAttr "AT_ID" xpText)
            (xpOption xpText)
   where
-    from_tuple = uncurry ScheduleChangesListingAwayTeamXml
-    to_tuple t = (away_team_id t,
-                  away_team_name t)
+    from_tuple = uncurry ScheduleChangesListingTeamXml
+    to_tuple t = (xml_team_id t,
+                  xml_team_name t)
 
 
--- | An (un)pickler for the \<Home_Team\> elements.
+-- | An (un)pickler for the \<Away_Team\> elements.
 --
-pickle_home_team :: PU ScheduleChangesListingHomeTeamXml
+pickle_home_team :: PU ScheduleChangesListingTeamXml
 pickle_home_team =
   xpElem "Home_Team" $
     xpWrap (from_tuple, to_tuple) $
     xpPair (xpAttr "HT_ID" xpText)
            (xpOption xpText)
   where
-    from_tuple = uncurry ScheduleChangesListingHomeTeamXml
-    to_tuple t = (home_team_id t,
-                  home_team_name t)
+    from_tuple = uncurry ScheduleChangesListingTeamXml
+    to_tuple t = (xml_team_id t,
+                  xml_team_name t)
 
 
 -- | An (un)pickler for the \<status\> elements.