Skip to content

Commit

Permalink
Adds PPG Column to Season-Long Records Tables (#92)
Browse files Browse the repository at this point in the history
* commit on add-ppg-column-records

* update version

* ensure no 0 denominator

Co-authored-by: OldNewsBlues <kovacsjc@gmail.com>
Co-authored-by: Nicholas Melhado <n.melhado@gmail.com>
  • Loading branch information
3 people authored Jan 3, 2022
1 parent ef631ae commit 837def7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.2.11] - 2021-01-03

### Added

- PPG Records [#92](https://github.com/nmelhado/league-page/issues/92)
- Big thank you to [OldNewsBlues](https://github.com/OldNewsBlues) for implementing this

## [1.2.10] - 2022-01-03

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "league-page",
"version": "1.2.10",
"version": "1.2.11",
"homepage": "https://github.com/nmelhado/league-page",
"repository": {
"type": "git",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Records/AllTimeRecords.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
for(const key in leagueRosterRecords) {
const leagueRosterRecord = leagueRosterRecords[key];
const denominator = (leagueRosterRecord.wins + leagueRosterRecord.ties + leagueRosterRecord.losses) > 0 ? (leagueRosterRecord.wins + leagueRosterRecord.ties + leagueRosterRecord.losses) : 1;
winPercentages.push({
rosterID: key,
manager: currentManagers[key],
percentage: round((leagueRosterRecord.wins + leagueRosterRecord.ties / 2) / (leagueRosterRecord.wins + leagueRosterRecord.ties + leagueRosterRecord.losses) * 100),
percentage: round((leagueRosterRecord.wins + leagueRosterRecord.ties / 2) / denominator * 100),
wins: leagueRosterRecord.wins,
ties: leagueRosterRecord.ties,
losses: leagueRosterRecord.losses,
Expand All @@ -55,6 +56,7 @@
manager: currentManagers[key],
fptsFor: round(leagueRosterRecord.fptsFor),
fptsAgainst: round(leagueRosterRecord.fptsAgainst),
fptsPerGame: round(leagueRosterRecord.fptsFor / denominator),
})
if(leagueRosterRecord.ties > 0) showTies = true;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/Records/PerSeasonRecords.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@
}
const fpts = round(season.fpts);
const fptsPerGame = round(season.fptsPerGame);
// add season-long scoring record
yearsObj[season.year].seasonLongRecords.push({
manager: season.manager,
rosterID,
fpts,
fptsPerGame,
year: null,
})
Expand Down Expand Up @@ -93,6 +95,7 @@
manager: season.manager,
fptsFor: round(season.fpts),
fptsAgainst: round(season.fptsAgainst),
fptsPerGame: round(season.fptsPerGame),
})
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/lib/Records/RecordsAndRankings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
<DataTable class="recordTable">
<Head>
<Row>
<Cell class="header" colspan=4>{prefix} Season-long Scoring Records</Cell>
<Cell class="header" colspan=5>{prefix} Season-long Scoring Records</Cell>
</Row>
<Row>
<Cell class="header rank"></Cell>
Expand All @@ -441,6 +441,7 @@
<Cell class="header">Year</Cell>
{/if}
<Cell class="header">Total Points</Cell>
<Cell class="header">PPG</Cell>
</Row>
</Head>
<Body>
Expand All @@ -457,6 +458,7 @@
<Cell>{mostSeasonLongPoint.year}</Cell>
{/if}
<Cell>{mostSeasonLongPoint.fpts}</Cell>
<Cell>{mostSeasonLongPoint.fptsPerGame}</Cell>
</Row>
{/each}
</Body>
Expand Down Expand Up @@ -632,7 +634,7 @@
<DataTable class="rankingTable">
<Head>
<Row>
<Cell class="header" colspan=4>
<Cell class="header" colspan=5>
{prefix} Fantasy Points Rankings
</Cell>
</Row>
Expand All @@ -641,6 +643,7 @@
<Cell class="header">Manager</Cell>
<Cell class="header">Points For</Cell>
<Cell class="header">Points Against</Cell>
<Cell class="header">Points Per Game</Cell>
</Row>
</Head>
<Body>
Expand All @@ -655,6 +658,7 @@
</Cell>
<Cell>{fptsHistory.fptsFor}</Cell>
<Cell>{fptsHistory.fptsAgainst}</Cell>
<Cell>{fptsHistory.fptsPerGame}</Cell>
</Row>
{/each}
</Body>
Expand Down
4 changes: 4 additions & 0 deletions src/lib/utils/helperFunctions/leagueRecords.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getLeagueUsers } from "./leagueUsers"
import { waitForAll } from './multiPromise';
import { get } from 'svelte/store';
import {records} from '$lib/stores';
import { round } from './universalFunctions';

export const getLeagueRecords = async (refresh = false) => {
if(get(records).seasonWeekRecords) {
Expand Down Expand Up @@ -99,6 +100,7 @@ export const getLeagueRecords = async (refresh = false) => {

const fpts = roster.settings.fpts + (roster.settings.fpts_decimal / 100);
const fptsAgainst = roster.settings.fpts_against + (roster.settings.fpts_against_decimal / 100);
const fptsPerGame = fpts / (roster.settings.wins + roster.settings.losses + roster.settings.ties);
const potentialPoints = roster.settings.ppts + (roster.settings.ppts_decimal / 100);

// add records to league roster record record
Expand All @@ -116,6 +118,7 @@ export const getLeagueRecords = async (refresh = false) => {
ties: roster.settings.ties,
fpts,
fptsAgainst,
fptsPerGame,
potentialPoints,
manager: originalManagers[rosterID],
year
Expand All @@ -126,6 +129,7 @@ export const getLeagueRecords = async (refresh = false) => {
mostSeasonLongPoints.push({
rosterID,
fpts,
fptsPerGame: round(fptsPerGame),
year,
manager: originalManagers[rosterID]
})
Expand Down
2 changes: 1 addition & 1 deletion src/lib/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ available for your copy of League Page
*/

// Keep in sync with package.json
export const version = "1.2.10";
export const version = "1.2.11";

0 comments on commit 837def7

Please sign in to comment.