]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/Odds.hs
Don't bother with the three-character limit on team_id fields; Postgres doesn't care.
[dead/htsn-import.git] / src / TSN / XML / Odds.hs
index 51ef0cabc5a003475d5de4e4a667c832ad70ed4c..467dbcf8ee6df3bf69241f35e5bad97cff2a3e1d 100644 (file)
@@ -62,7 +62,7 @@ import Text.XML.HXT.Core (
 import TSN.Codegen (
   tsn_codegen_config )
 import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
-import TSN.Picklers ( xp_date, xp_team_id, xp_time )
+import TSN.Picklers ( xp_date, xp_time )
 import TSN.XmlImport ( XmlImport(..) )
 import Xml ( FromXml(..), pickle_unpickle, unpickleable )
 
@@ -124,7 +124,12 @@ instance XmlImport OddsGameCasinoXml
 --
 data OddsGameTeam =
   OddsGameTeam {
-    db_team_id         :: String, -- ^ The home/away team IDs are 3 characters
+    db_team_id         :: String, -- ^ The home/away team IDs are
+                                  --   three characters but Postgres
+                                  --   imposes no performance penalty
+                                  --   on lengthless text fields, so
+                                  --   we ignore the probable upper
+                                  --   bound of three characters.
     db_abbr            :: String,
     db_team_name       :: String }
   deriving (Eq, Show)
@@ -134,7 +139,14 @@ data OddsGameTeam =
 --
 data OddsGameHomeTeamXml =
   OddsGameHomeTeamXml {
-    xml_home_team_id         :: String, -- ^ These are three-character IDs.
+    xml_home_team_id         :: String, -- ^ The home/away team IDs
+                                        --   are three characters but
+                                        --   Postgres imposes no
+                                        --   performance penalty on
+                                        --   lengthless text fields,
+                                        --   so we ignore the probable
+                                        --   upper bound of three
+                                        --   characters.
     xml_home_rotation_number :: Int,
     xml_home_abbr            :: String,
     xml_home_team_name       :: String,
@@ -168,7 +180,12 @@ instance XmlImport OddsGameHomeTeamXml where
 --
 data OddsGameAwayTeamXml =
   OddsGameAwayTeamXml {
-    xml_away_team_id         :: String, -- ^ These are 3 character IDs.
+    xml_away_team_id         :: String, -- ^ The home/away team IDs are
+                                        --   three characters but Postgres
+                                        --   imposes no performance penalty
+                                        --   on lengthless text fields, so
+                                        --   we ignore the probable upper
+                                        --   bound of three characters
     xml_away_rotation_number :: Int,
     xml_away_abbr            :: String,
     xml_away_team_name       :: String,
@@ -297,7 +314,11 @@ data Odds =
   Odds {
     db_sport :: String,
     db_title :: String,
-    db_line_time :: String }
+    db_line_time :: String -- ^ We don't parse these as a 'UTCTime'
+                           --   because their timezones are ambiguous
+                           --   (and the date is less than useful when
+                           --   it might be off by an hour).
+  }
 
 
 -- | Map 'Odds' to their children 'OddsGame's.
@@ -385,9 +406,6 @@ mkPersist tsn_codegen_config [groundhog|
   dbName: odds_games_teams
   constructors:
     - name: OddsGameTeam
-      fields:
-        - name: db_team_id
-          type: varchar(3) # We've only seen 3, so far...
       uniques:
         - name: unique_odds_games_team
           type: constraint
@@ -537,7 +555,7 @@ pickle_home_team =
   xpElem "HomeTeam" $
     xpWrap (from_tuple, to_tuple) $
       xp5Tuple
-        (xpElem "HomeTeamID" xp_team_id)
+        (xpElem "HomeTeamID" xpText)
         (xpElem "HomeRotationNumber" xpInt)
         (xpElem "HomeAbbr" xpText)
         (xpElem "HomeTeamName" xpText)
@@ -559,7 +577,7 @@ pickle_away_team =
   xpElem "AwayTeam" $
     xpWrap (from_tuple, to_tuple) $
       xp5Tuple
-        (xpElem "AwayTeamID" xp_team_id)
+        (xpElem "AwayTeamID" xpText)
         (xpElem "AwayRotationNumber" xpInt)
         (xpElem "AwayAbbr" xpText)
         (xpElem "AwayTeamName" xpText)