pickle_unpickle,
unpickleable )
+
+--
+-- DB/XML Data types
+--
+
+-- * InjuriesTeam
+
-- | XML/Database representation of a team as they appear in the
-- injuries documents.
--
deriving (Data, Eq, Show, Typeable)
+-- * InjuriesListing/InjuriesListingXml
+
-- | XML/Database representation of the injury listings.
--
data InjuriesListingXml =
instance XmlImportFk InjuriesListingXml
+
+-- * Injuries/Message
+
-- | XML representation of an injuriesxml \<message\>.
--
data Message =
--
data Injuries =
Injuries {
+ db_xml_file_id :: Int,
db_sport :: String,
db_time_stamp :: UTCTime }
--
from_xml Message{..} =
Injuries {
+ db_xml_file_id = xml_xml_file_id,
db_sport = xml_sport,
db_time_stamp = xml_time_stamp }
instance XmlImport Message
+--
+-- Database code
+--
+
instance DbImport Message where
dbmigrate _ =
run_dbmigrate $ do
mkPersist tsn_codegen_config [groundhog|
- entity: Injuries
+ constructors:
+ - name: Injuries
+ uniques:
+ - name: unique_injuries
+ type: constraint
+ # Prevent multiple imports of the same message.
+ fields: [db_xml_file_id]
- entity: InjuriesListing
dbName: injuries_listings
|]
+--
+-- XML Picklers
+--
+
+
-- | A pickler for 'InjuriesTeam's that can convert them to/from XML.
--
pickle_injuries_team :: PU InjuriesTeam
to_tuple m = (db_team_name m, db_team_league m)
--- | A pickler for 'InjuriesListingXml's that can convert them to/from XML.
+-- | A pickler for 'InjuriesListingXml's that can convert them to/from
+-- XML.
--
pickle_listing :: PU InjuriesListingXml
pickle_listing =