-- | The format string for a base date in m/d/yyyy format. The
-- day/month are not padded at all. This will match for example,
--
--- * 2/15/1983
--- * 1/1/0000
+-- * 2\/15\/1983
+--
+-- * 1\/1\/0000
--
date_format :: String
date_format = "%-m/%-d/%Y"
-- day/month are padded to two characters with zeros. This will
-- match for example,
--
--- * 02/15/1983
--- * 01/01/0000
+-- * 02\/15\/1983
+--
+-- * 01\/01\/0000
--
date_format_padded :: String
date_format_padded = "%0m/%0d/%Y"
-- | Parse \<Earnings\> from an 'AutoRaceResultsListing'. These are
-- essentially 'Int's, but they look like,
--
--- * <Earnings>336,826</Earnings>
--- * <Earnings>1,000,191</Earnings>
--- * <Earnings>TBA</Earnings>
+-- * \<Earnings\>336,826\</Earnings\>
+--
+-- * \<Earnings\>1,000,191\</Earnings\>
+--
+-- * \<Earnings\>TBA\</Earnings\>
--
xp_earnings :: PU (Maybe Int)
xp_earnings =
-- | (Un)pickle a 'UTCTime' from a \<RaceDate\> element in an
-- 'AutoRaceResults' message.
--
--- Example:
+-- Examples:
+--
+-- * \<RaceDate\>6/1/2014 1:00:00 PM\</RaceDate\>
--
--- <RaceDate>6/1/2014 1:00:00 PM</RaceDate>
--- <RaceDate>5/24/2014 2:45:00 PM</RaceDate>
+-- * \<RaceDate\>5/24/2014 2:45:00 PM\</RaceDate\>
--
xp_racedate :: PU UTCTime
xp_racedate =
-- * AutoRacingResults/Message
--- | Database representation of a 'Message'.
+-- | Database representation of a 'Message'. Comparatively, it lacks
+-- the listings and race information since they are linked via a
+-- foreign key.
--
data AutoRacingResults =
AutoRacingResults {
--- | XML Representation of an 'AutoRacingResults'.
+-- | XML Representation of an 'AutoRacingResults'. It has the same
+-- fields, but in addition contains the 'xml_listings' and
+-- 'xml_race_information'.
--
data Message =
Message {
db_nc :: Maybe Bool,
db_earnings :: Maybe Int }
+
-- | XML representation of a \<Listing\> contained within a
-- \<message\>.
--
--
type Db AutoRacingResultsListingXml = AutoRacingResultsListing
+
instance FromXmlFk AutoRacingResultsListingXml where
-- | Each 'AutoRacingResultsListingXml' is contained in (i.e. has a
-- foreign key to) a 'AutoRacingResults'.
onDelete: cascade
- name: db_most_laps_leading
embeddedType:
- - {name: most_laps_leading_driver_id, dbName: most_laps_leading_driver_id}
- - {name: most_laps_leading_driver, dbName: most_laps_leading_driver}
+ - {name: most_laps_leading_driver_id,
+ dbName: most_laps_leading_driver_id}
+ - {name: most_laps_leading_driver,
+ dbName: most_laps_leading_driver}
- embedded: MostLapsLeading
fields:
--- Pickling
---
+-- | Pickler for the \<Listing\>s contained within \<message\>s.
+--
pickle_listing :: PU AutoRacingResultsListingXml
pickle_listing =
xpElem "Listing" $
-- | Pickler for the top-level 'Message'.
+--
pickle_message :: PU Message
pickle_message =
xpElem "message" $
xml_time_stamp m)
+-- | Pickler for the \<Most_Laps_Leading\> child of a
+-- \<Race_Information\>.
+--
pickle_most_laps_leading :: PU MostLapsLeading
pickle_most_laps_leading =
xpElem "Most_Laps_Leading" $
db_most_laps_leading_driver m,
db_most_laps_leading_number_of_laps m)
+
+-- | Pickler for the \<Race_Information\> child of \<message\>.
+--
pickle_race_information :: PU AutoRacingResultsRaceInformationXml
pickle_race_information =
xpElem "Race_Information" $
deriving (Eq, Show)
--- * AutoRacingScheduleListingRaceResultRaceResultListing /
--- AutoRacingScheduleListingRaceResultRaceResultListingXml
+-- * AutoRacingScheduleListingRaceResultRaceResultListing / AutoRacingScheduleListingRaceResultRaceResultListingXml
--
-- Sorry about the names yo.
--
unsafe_read_document )
--- | The DTDs for everything that we consider "Game Info."
+-- | The DTDs for everything that we consider \"Game Info.\"
--
-- TODO: This is the list from the old implementation. We need to
-- make sure that we are really receiving XML for these DTDs
-- * ScoreGame_ScoreGameTeam
-- | Join a 'ScoreGame' with its home/away teams. Database-only. We
--- use a join table because the teams are kept unique.
+-- use a join table because the teams are kept unique. The first
+-- argument is the game id, the second argument is the visiting team
+-- (vteam) id, and the last argument is the home team (hteam) id.
--
data ScoreGame_ScoreGameTeam =
ScoreGame_ScoreGameTeam
- (DefaultKey ScoreGame) -- ^ game id
- (DefaultKey ScoreGameTeam) -- ^ vteam id
- (DefaultKey ScoreGameTeam) -- ^ hteam id
+ (DefaultKey ScoreGame) -- game id
+ (DefaultKey ScoreGameTeam) -- vteam id
+ (DefaultKey ScoreGameTeam) -- hteam id
-- * ScoreLocation
unsafe_read_document )
--- | The DTDs for everything that we consider "Sport Info."
+-- | The DTDs for everything that we consider \"Sport Info.\"
--
-- TODO: This is the list from the old implementation. We need to
-- make sure that we are really receiving XML for these DTDs