From 9f8805d6aa95283e9e2d99259a17cb8c72f6ca62 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 4 Jul 2014 00:23:53 -0400 Subject: [PATCH] Fix misleading comments and reorder two operations in JFile/Odds. --- src/TSN/XML/JFile.hs | 8 +++----- src/TSN/XML/Odds.hs | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/TSN/XML/JFile.hs b/src/TSN/XML/JFile.hs index 86565ca..d2ac6f4 100644 --- a/src/TSN/XML/JFile.hs +++ b/src/TSN/XML/JFile.hs @@ -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. diff --git a/src/TSN/XML/Odds.hs b/src/TSN/XML/Odds.hs index 8061a3e..2ad2d93 100644 --- a/src/TSN/XML/Odds.hs +++ b/src/TSN/XML/Odds.hs @@ -535,15 +535,13 @@ instance DbImport Message where 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. -- 2.43.2