Refactor project structure and update configurations
- Renamed and deleted several Python modules - Added new SQL and database scripts - Updated `.vscode` and `requirements.txt` configurations
This commit is contained in:
22
sql_scripts/get_game_details.sql
Normal file
22
sql_scripts/get_game_details.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
SELECT
|
||||
game.id,
|
||||
game.date,
|
||||
team_home.name AS home_team,
|
||||
team_visitor.name AS visitor_team,
|
||||
venue.name AS venue_name,
|
||||
gameresult.home_runs_for,
|
||||
gameresult.visitor_runs_for,
|
||||
gameresult.home_outcome,
|
||||
gameresult.visitor_outcome
|
||||
FROM
|
||||
game
|
||||
JOIN
|
||||
team AS team_home ON game.home_team_id = team_home.id
|
||||
JOIN
|
||||
team AS team_visitor ON game.visitor_team_id = team_visitor.id
|
||||
JOIN
|
||||
venue ON game.venue_id = venue.id
|
||||
LEFT JOIN
|
||||
gameresult ON game.id = gameresult.game_id
|
||||
ORDER BY
|
||||
game.date;
|
||||
26
sql_scripts/get_standings.sql
Normal file
26
sql_scripts/get_standings.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
SELECT
|
||||
strftime('%Y', game.date) AS year, -- Extracts year from date
|
||||
team.id AS team_id,
|
||||
team.name AS team_name,
|
||||
SUM(CASE
|
||||
WHEN gameresult.home_outcome = 'WIN' AND game.home_team_id = team.id
|
||||
OR gameresult.visitor_outcome = 'WIN' AND game.visitor_team_id = team.id
|
||||
THEN 1 ELSE 0 END) AS wins,
|
||||
SUM(CASE
|
||||
WHEN gameresult.home_outcome = 'LOSS' AND game.home_team_id = team.id
|
||||
OR gameresult.visitor_outcome = 'LOSS' AND game.visitor_team_id = team.id
|
||||
THEN 1 ELSE 0 END) AS losses,
|
||||
SUM(CASE
|
||||
WHEN gameresult.home_outcome = 'TIE' AND game.home_team_id = team.id
|
||||
OR gameresult.visitor_outcome = 'TIE' AND game.visitor_team_id = team.id
|
||||
THEN 1 ELSE 0 END) AS ties
|
||||
FROM
|
||||
team
|
||||
LEFT JOIN
|
||||
game ON (game.home_team_id = team.id OR game.visitor_team_id = team.id)
|
||||
LEFT JOIN
|
||||
gameresult ON game.id = gameresult.game_id
|
||||
GROUP BY
|
||||
year, team.id
|
||||
ORDER BY
|
||||
year, wins DESC, losses ASC, ties DESC;
|
||||
Reference in New Issue
Block a user