-- 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.
odds_id <- insert_xml m
forM_ (xml_games m) $ \g -> do
- -- 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".
+ -- First insert the game, keyed to the "odds",
+ game_id <- insert_xml_fk odds_id g
+
+ -- Next, we insert the home and away teams.
away_team_id <- insert_xml_or_select (xml_away_team g)
home_team_id <- insert_xml_or_select (xml_home_team g)
- -- Now insert the game, keyed to the "odds",
- game_id <- insert_xml_fk odds_id g
-
-- Insert a record into odds_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.