X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FJFile.hs;h=fa37e7c636dcd44166284fb005ffccb4e4549d7d;hb=2dd1ab7a375b55632f6c8165dce97a2df3cc1907;hp=86565ca59153541a9796aaabe2a2231c0c7f271e;hpb=4f3de61fd6e53c74a8c1a7a6b1d478a5571591d9;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/JFile.hs b/src/TSN/XML/JFile.hs index 86565ca..fa37e7c 100644 --- a/src/TSN/XML/JFile.hs +++ b/src/TSN/XML/JFile.hs @@ -174,8 +174,8 @@ instance FromXml JFileGameAwayTeamXml where from_xml JFileGameAwayTeamXml{..} = Team { team_id = away_team_id, - team_abbreviation = away_team_abbreviation, - team_name = away_team_name } + abbreviation = away_team_abbreviation, + name = away_team_name } -- | Allow us to import JFileGameAwayTeamXml directly. instance XmlImport JFileGameAwayTeamXml @@ -204,8 +204,8 @@ instance FromXml JFileGameHomeTeamXml where from_xml JFileGameHomeTeamXml{..} = Team { team_id = home_team_id, - team_abbreviation = home_team_abbreviation, - team_name = home_team_name } + abbreviation = home_team_abbreviation, + name = home_team_name } -- | Allow us to import JFileGameHomeTeamXml directly. instance XmlImport JFileGameHomeTeamXml @@ -387,15 +387,13 @@ instance DbImport Message where -- Now loop through the message's games forM_ (xml_games $ xml_gamelist m) $ \game -> do + -- First insert the game, keyed to the "jfile", + game_id <- insert_xml_fk msg_id game - -- Next, we insert the home and away teams. We do this before - -- inserting the game itself because the game has two foreign keys - -- pointing to "teams". + -- Next, we insert the home and away teams. away_team_id <- insert_xml_or_select (xml_vteam game) home_team_id <- insert_xml_or_select (xml_hteam game) - game_id <- insert_xml_fk msg_id game - -- Insert a record into jfile_games__teams mapping the -- home/away teams to this game. Use the full record syntax -- because the types would let us mix up the home/away teams.