]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/AutoRacingResults.hs
Minor comment fix.
[dead/htsn-import.git] / src / TSN / XML / AutoRacingResults.hs
index 370ae8174c59a52992ac78eed3efebfb009e9bde..cd5ebec36010eeefc7f9132d02bc1d3f7ae58892 100644 (file)
@@ -57,8 +57,7 @@ import Text.XML.HXT.Core (
   xpWrap )
 
 -- Local imports.
-import TSN.Codegen (
-  tsn_codegen_config )
+import TSN.Codegen ( tsn_codegen_config )
 import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
 import TSN.Picklers ( xp_earnings, xp_datetime, xp_time_stamp )
 import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
@@ -272,7 +271,8 @@ data AutoRacingResultsRaceInformation =
     -- Note the apostrophe to disambiguate it from the
     -- AutoRacingResultsListing field.
     db_auto_racing_results_id' :: DefaultKey AutoRacingResults,
-    db_track_length :: Double,
+    db_track_length :: String, -- ^ Usually a Double, but sometimes a String,
+                               --   like \"1.25 miles\".
     db_track_length_kph :: Double,
     db_laps :: Int,
     db_average_speed_mph :: Maybe Double,
@@ -291,7 +291,7 @@ data AutoRacingResultsRaceInformation =
 --
 data AutoRacingResultsRaceInformationXml =
   AutoRacingResultsRaceInformationXml {
-    xml_track_length :: Double,
+    xml_track_length :: String,
     xml_track_length_kph :: Double,
     xml_laps :: Int,
     xml_average_speed_mph :: Maybe Double,
@@ -351,9 +351,9 @@ instance XmlImportFk AutoRacingResultsRaceInformationXml
 
 
 
----
---- Database stuff.
----
+--
+-- * Database stuff.
+--
 
 instance DbImport Message where
   dbmigrate _ =
@@ -369,8 +369,7 @@ instance DbImport Message where
 
     insert_xml_fk_ msg_id (xml_race_information m)
 
-    forM_ (xml_listings m) $ \listing -> do
-      insert_xml_fk_ msg_id listing
+    forM_ (xml_listings m) $ insert_xml_fk_ msg_id
 
     return ImportSucceeded
 
@@ -382,7 +381,7 @@ mkPersist tsn_codegen_config [groundhog|
   constructors:
     - name: AutoRacingResults
       uniques:
-        - name: unique_auto_racing_schedule
+        - name: unique_auto_racing_results
           type: constraint
           # Prevent multiple imports of the same message.
           fields: [db_xml_file_id]
@@ -397,9 +396,9 @@ mkPersist tsn_codegen_config [groundhog|
           reference:
             onDelete: cascade
 
-# Note the apostrophe in the foreign key. This is to disambiguate
-# it from the AutoRacingResultsListing foreign key of the same name.
-# We strip it out of the dbName.
+  # Note the apostrophe in the foreign key. This is to disambiguate
+  # it from the AutoRacingResultsListing foreign key of the same name.
+  # We strip it out of the dbName.
 - entity: AutoRacingResultsRaceInformation
   dbName: auto_racing_results_race_information
   constructors:
@@ -529,7 +528,7 @@ pickle_race_information =
     xp11Tuple (-- I can't think of another way to get both the
                -- TrackLength and its KPH attribute. So we shove them
                -- both in a 2-tuple. This should probably be an embedded type!
-                 xpElem "TrackLength" $ xpPair xpPrim (xpAttr "KPH" xpPrim) )
+                 xpElem "TrackLength" $ xpPair xpText (xpAttr "KPH" xpPrim) )
               (xpElem "Laps" xpInt)
               (xpOption $ xpElem "AverageSpeedMPH" xpPrim)
               (xpOption $ xpElem "AverageSpeedKPH" xpPrim)
@@ -561,7 +560,7 @@ pickle_race_information =
                   xml_most_laps_leading m)
 
 --
--- Tasty Tests
+-- Tasty Tests
 --
 
 -- | A list of all tests for this module.