From 5fab11f240d5632f1847b658426805861d7b4d70 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 5 Jul 2014 21:16:01 -0400 Subject: [PATCH] Remove redundant away team XML representation in ScheduleChanges. --- src/TSN/XML/ScheduleChanges.hs | 90 +++++++++++----------------------- 1 file changed, 28 insertions(+), 62 deletions(-) diff --git a/src/TSN/XML/ScheduleChanges.hs b/src/TSN/XML/ScheduleChanges.hs index 5f0eff2..5dc6872 100644 --- a/src/TSN/XML/ScheduleChanges.hs +++ b/src/TSN/XML/ScheduleChanges.hs @@ -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 \ 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 \ elements. +-- | An (un)pickler for the \ 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 \ elements. -- 2.44.2