Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing draft board bug #251

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

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

## [2.2.8] - 2023-08-21

### Fixed

- If a league did multiple drafts in the same season (startup and rookie for example), only the most recent was displayed. This ensures that all drafts from a particular season are displayed. [(issue #240)](https://github.com/nmelhado/league-page/issues/240)

## [2.2.7] - 2023-08-21

### Fixed

- Some matchups only had one team in the matchup (playing themselves ????), which caused bugs in any page that touched league records
- Some matchups only had one team in the matchup (playing themselves ????), which caused bugs in any page that touched league records [(issue #244)](https://github.com/nmelhado/league-page/issues/244)

## [2.2.6] - 2023-07-25

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": "2.2.7",
"version": "2.2.8",
"homepage": "https://github.com/nmelhado/league-page",
"repository": {
"type": "git",
Expand Down
80 changes: 44 additions & 36 deletions src/lib/utils/helperFunctions/leagueDrafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,43 +184,51 @@ export const getPreviousDrafts = async () => {
const drafts = [];

while(curSeason && curSeason != 0) {
const leagueData = await getLeagueData(curSeason).catch((err) => { console.error(err); });
const [leagueData, completedDraftsInfo] = await waitForAll(
getLeagueData(curSeason).catch((err) => { console.error(err); }),
fetch(`https://api.sleeper.app/v1/league/${curSeason}/drafts`, {compress: true}),
).catch((err) => { console.error(err); });

const completedDrafts = await completedDraftsInfo.json();
curSeason = leagueData.previous_league_id;

for(const completedDraft of completedDrafts) {
const draftID = completedDraft.draft_id;
const year = parseInt(completedDraft.season);

const [officialDraftRes, picksRes, playersRes] = await waitForAll(
fetch(`https://api.sleeper.app/v1/draft/${draftID}`, {compress: true}),
fetch(`https://api.sleeper.app/v1/draft/${draftID}/traded_picks`, {compress: true}),
fetch(`https://api.sleeper.app/v1/draft/${draftID}/picks`, {compress: true}),
).catch((err) => { console.error(err); });

const [officialDraft, picks, players] = await waitForAll(
officialDraftRes.json(),
picksRes.json(),
playersRes.json(),
).catch((err) => { console.error(err); });

if(officialDraft.status != "complete") continue;

let draft;
let draftOrder;


const buildRes = buildConfirmed(officialDraft.slot_to_roster_id, officialDraft.settings.rounds, picks, players, officialDraft.type);
draft = buildRes.draft;
draftOrder = buildRes.draftOrder;

const newDraft = {
year,
draft,
draftOrder,
draftType: officialDraft.type,
reversalRound: officialDraft.settings.reversal_round,
}

drafts.push(newDraft);
}

const draftID = leagueData.draft_id;
let year = parseInt(leagueData.season);
curSeason = leagueData.previous_league_id;

const [officialDraftRes, picksRes, playersRes] = await waitForAll(
fetch(`https://api.sleeper.app/v1/draft/${draftID}`, {compress: true}),
fetch(`https://api.sleeper.app/v1/draft/${draftID}/traded_picks`, {compress: true}),
fetch(`https://api.sleeper.app/v1/draft/${draftID}/picks`, {compress: true}),
).catch((err) => { console.error(err); });

const [officialDraft, picks, players] = await waitForAll(
officialDraftRes.json(),
picksRes.json(),
playersRes.json(),
).catch((err) => { console.error(err); });

if(officialDraft.status != "complete") continue;

let draft;
let draftOrder;


const buildRes = buildConfirmed(officialDraft.slot_to_roster_id, officialDraft.settings.rounds, picks, players, officialDraft.type);
draft = buildRes.draft;
draftOrder = buildRes.draftOrder;

const newDraft = {
year,
draft,
draftOrder,
draftType: officialDraft.type,
reversalRound: officialDraft.settings.reversal_round,
}

drafts.push(newDraft);
}

previousDrafts.update(() => drafts);
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 = "2.2.7";
export const version = "2.2.8";