Skip to content

Commit

Permalink
Added Supporters & NWSL Shields count. Fixed LAFC Data
Browse files Browse the repository at this point in the history
  • Loading branch information
Durhamster committed Nov 23, 2022
1 parent 0571934 commit 18c2148
Show file tree
Hide file tree
Showing 12 changed files with 577 additions and 334 deletions.
26 changes: 25 additions & 1 deletion src/components/all_sports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,51 @@ export const TeamData = function (
total_losses += losses;
}

// Championship wins & losses
let ch_win_years: any = team_ch_wins.map((o: any) => o.yearID);
let ch_wins = Object.keys(ch_win_years).length;

let ch_ru_years: any = team_ch_apps.map((o: any) => o.yearID);
let ch_rus = Object.keys(ch_ru_years).length;

// Checks for league. Some data sets use runners up while others count appearances
if (league == "MLB") {
if (league == "MLB" || league == "MLS") {
var ch_apps = ch_rus - ch_wins;
} else {
var ch_apps = ch_rus;
}

// Total games played & win rate
let total_games = total_wins + total_draws + total_losses;

// Checks for Supporters & NWSL Shields (MLS & NWSL)
if (league == "MLS") {
var shields_won: any = team_year_dict.filter(
(o: any) => o["supporters_shield"] == "Y"
);

var shield_years: any = shields_won.map((o: any) => o.yearID);
var shields = Object.keys(shield_years).length;
} else if (league == "NWSL") {
var shields_won: any = team_year_dict.filter(
(o: any) => o["NWSL_Shield"] == "Y"
);

var shield_years: any = shields_won.map((o: any) => o.yearID);
var shields: number = Object.keys(shield_years).length;
} else {
var shields: number = 0;
}

console.log(shields);

return {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
};
};
64 changes: 40 additions & 24 deletions src/components/am_football.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,47 +64,63 @@ export const nfl_dropdown = `<select

// Team Data Funcs
export const CFLTeamData = function (birth_year: any, franchiseID: any) {
let { total_games, total_wins, total_draws, total_losses, ch_wins, ch_apps } =
TeamData(
"am_football",
"CFL",
birth_year,
franchiseID,
cfl_data,
"CH",
"Won Grey Cup",
"CH",
"Lost Grey Cup"
);
let {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
} = TeamData(
"am_football",
"CFL",
birth_year,
franchiseID,
cfl_data,
"CH",
"Won Grey Cup",
"CH",
"Lost Grey Cup"
);
return {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
};
};

export const NFLTeamData = function (birth_year: any, franchiseID: any) {
let { total_games, total_wins, total_draws, total_losses, ch_wins, ch_apps } =
TeamData(
"am_football",
"NFL",
birth_year,
franchiseID,
nfl_data,
"ch_sb_win",
"Y",
"ch_sb_app",
"Y"
);
let {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
} = TeamData(
"am_football",
"NFL",
birth_year,
franchiseID,
nfl_data,
"ch_sb_win",
"Y",
"ch_sb_app",
"Y"
);
return {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
};
};
128 changes: 80 additions & 48 deletions src/components/baseball.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,93 +97,125 @@ autocomplete="off">

// Team Data Funcs
export const CPBLTeamData = function (birth_year: any, franchiseID: any) {
let { total_games, total_wins, total_draws, total_losses, ch_wins, ch_apps } =
TeamData(
"baseball",
"CPBL",
birth_year,
franchiseID,
cpbl_data,
"Cwin",
"Y",
"CRU",
"Y"
);
let {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
} = TeamData(
"baseball",
"CPBL",
birth_year,
franchiseID,
cpbl_data,
"Cwin",
"Y",
"CRU",
"Y"
);
return {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
};
};

export const KBOTeamData = function (birth_year: any, franchiseID: any) {
let { total_games, total_wins, total_draws, total_losses, ch_wins, ch_apps } =
TeamData(
"baseball",
"KBO",
birth_year,
franchiseID,
kbo_data,
"ch_win",
"Y",
"ch_app",
"Y"
);
let {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
} = TeamData(
"baseball",
"KBO",
birth_year,
franchiseID,
kbo_data,
"ch_win",
"Y",
"ch_app",
"Y"
);
return {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
};
};

export const MLBTeamData = function (birth_year: any, franchiseID: any) {
let { total_games, total_wins, total_draws, total_losses, ch_wins, ch_apps } =
TeamData(
"baseball",
"MLB",
birth_year,
franchiseID,
mlb_data,
"WSWin",
"Y",
"LgWin",
"Y"
);
let {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
} = TeamData(
"baseball",
"MLB",
birth_year,
franchiseID,
mlb_data,
"WSWin",
"Y",
"LgWin",
"Y"
);
return {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
};
};

export const NPBTeamData = function (birth_year: any, franchiseID: any) {
let { total_games, total_wins, total_draws, total_losses, ch_wins, ch_apps } =
TeamData(
"baseball",
"NPB",
birth_year,
franchiseID,
npb_data,
"Cwin",
"Y",
"CRU",
"Y"
);
let {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
} = TeamData(
"baseball",
"NPB",
birth_year,
franchiseID,
npb_data,
"Cwin",
"Y",
"CRU",
"Y"
);
return {
total_games,
total_wins,
total_draws,
total_losses,
ch_wins,
ch_apps,
shields,
};
};
Loading

0 comments on commit 18c2148

Please sign in to comment.