Skip to content

Commit cf8812a

Browse files
authored
Converting to tracking rankings by manager (nmelhado#185)
This PR holds several key changes - Rankings are now tracked by manager (for all time records as well as in the manager page) - This increases the overall accuracy of the Records and Rankings page (as well as the manager pages) - It now uses the league specific avatar (if one exists) - The chart style has been updated to better accommodate more entries (horizontal bars instead of vertical) - Waivers have received a face lift and now look much cleaner and better - Commissioner badge added on the managers pages Preview of changes below: | Old | New | |---|---| | ![old waivers](https://user-images.githubusercontent.com/39418000/211601742-568d71ff-e3e1-4419-8c23-2aed436b46d7.png) | ![new waivers](https://user-images.githubusercontent.com/39418000/211601802-6ec40035-569b-4d58-902e-4fa4d936f6aa.png) | | ![old waivers tr](https://user-images.githubusercontent.com/39418000/211602064-c2617271-12ba-40e9-acc5-ddfc53efb5ff.png) | ![new waivers tr](https://user-images.githubusercontent.com/39418000/211602119-cb56b85f-8f52-481e-86d2-9ee9722b6a2e.png) | | ![old records single](https://user-images.githubusercontent.com/39418000/211602226-72b5d79c-a8c8-40ab-920b-62ff879846e9.png) | ![new records - single](https://user-images.githubusercontent.com/39418000/211602267-cbb9ac26-c7c1-4eb7-8306-2fcc0c4e4776.png) | | ![old records vs](https://user-images.githubusercontent.com/39418000/211602352-814d3daa-a013-4548-bd00-b2fa99f7be89.png) | ![new records vs](https://user-images.githubusercontent.com/39418000/211602397-92b7275e-7ff9-4b05-b1fd-355f67c7bbb6.png) | | ![old chart](https://user-images.githubusercontent.com/39418000/211602484-f59b219a-bda8-4901-8d4c-f3d320453b0e.png) | ![new chart](https://user-images.githubusercontent.com/39418000/211602542-17908108-f74a-4e32-a7f0-b1d9883a6056.png) | __**Due to the enormity of this change, there may be bugs. I have done my best to check the edge conditions, but the scope of this is large enough that I may have missed some**__
1 parent bce68f2 commit cf8812a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1735
-1374
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

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

5+
## [2.1.0] - 2023-01-10
6+
7+
### Changed
8+
9+
- Rankings are now organize by manager instead of team! [(issue #164)](https://github.com/nmelhado/league-page/issues/164)
10+
- This means that if managers have changed throughout the years, you will now see accurate rankings for a given manager
11+
- **To take full advantage of this you need to add managerIDs to the managers object in leagueInfo`src/lib/utils/leagueInfo.js`**
12+
- More instructions in the updated [Training Wheels managers instructions](https://github.com/nmelhado/league-page/blob/master/TRAINING_WHEELS.md#2-add-managers)
13+
- Use league specific avatar if avilable [(issue #156)](https://github.com/nmelhado/league-page/issues/156)
14+
15+
### Fixed
16+
17+
- Standings order issue [(issue #179)](https://github.com/nmelhado/league-page/issues/179)
18+
- The re-implememntation of how team and user data is rendered should have fixed this
19+
520
## [2.0.2] - 2022-09-29
621

722
### Fixed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Generate a custom league page for your Sleeper fantasy football league in just a
6767
![league ID instructions](https://storage.googleapis.com/nfl-player-data/league_id_instructions.png)
6868
- Write your homepage text (league intro/bio) `/src/lib/utils/leagueInfo.js` (lines 9-14)
6969
![homepage text](https://storage.googleapis.com/nfl-player-data/homepage_text.png)
70-
- Next, fill out and uncomment (delete the `// ` at the beginning of each line) the managers' object (lines 27 - 92), also located in `/src/lib/utils/leagueInfo.js`, there should be one object for each manager (for assistance, consult the [Training Wheels guide](https://github.com/nmelhado/league-page/blob/master/TRAINING_WHEELS.md#ii-adding-managers-and-changing-the-homepage-text))
70+
- Next, fill out and uncomment (delete the `// ` at the beginning of each line) the managers' object (lines 27 - 92), also located in `/src/lib/utils/leagueInfo.js`, there should be one object for each manager. The structure may change in the future (it has already 😅). The source of truth is down at the bottom, lines 104-126 (for assistance, consult the [Training Wheels guide](https://github.com/nmelhado/league-page/blob/master/TRAINING_WHEELS.md#ii-adding-managers-and-changing-the-homepage-text)).
7171
![manager object](https://storage.googleapis.com/nfl-player-data/managersObj.png)
7272
![manager rendering](https://storage.googleapis.com/nfl-player-data/managerRendering.png)
7373
- Add corresponding images for managers to the `/static/managers/` directory and make the sure the name matches with what was provided above

TRAINING_WHEELS.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,14 @@ Generate a custom league page for your Sleeper fantasy football league in just a
117117
<br />
118118

119119
- Fill each one out as follows:
120-
- `"roster" :` give the roster ID for this manager
121-
- To find the roster ID for the manager, go back to your website and scroll down to the `Power Rankings` graph (or to any of the graphs in your records page)
122-
> ![pRankings](https://storage.googleapis.com/nfl-player-data/pRankings.png)
123-
124-
<br />
125-
126-
- The roster ID is the order of the bar chart, the first bar is roster ID 1, the second is roster ID 2, etc.
120+
- `"roster" :` **This has been deprecated! You can ignore this field as long as you provide a managerID**
121+
- ~~To find the roster ID for the manager, go back to your website and scroll down to the `Power Rankings` graph (or to any of the graphs in your records page)~~ (Power Rankings are no longer in order)
122+
- `"managerID" :` the user ID of the manager
123+
- To find a manager's user ID, go to `https://api.sleeper.app/v1/league/<your_league_id/users` (for example: https://api.sleeper.app/v1/league/784583295500464128/users) and find the corresponding userID for each manager
124+
- This feld was added in version 2.1.0, so you will have to add it manually. Remember when adding it, to place the id within quotes (i.e. `"managerID" : "12345678",`)
127125
- `"name" :` The name of this manager
128-
- `"tookOver" :` If this manager took over an orphaned team in your league, give the year they took over. Otherwise set this to `null`
126+
- `"tookOver" :` **This has been deprecated! You can ignore this field as long as you provide a managerID**
127+
- If this manager took over an orphaned team in your league, give the year they took over. Otherwise set this to `null`
129128
- `"location" :` Where is this manager based out of (City, State, Country, whatever floats your boat)
130129
- `"bio" :` This manager's bio. If you don't have a bio yet, leave it as is and come back and edit this again when you have the bio.
131130
- `"photo" :` This manager's photo. To upload a photo:

package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "league-page",
3-
"version": "2.0.2",
3+
"version": "2.1.0",
44
"homepage": "https://github.com/nmelhado/league-page",
55
"repository": {
66
"type": "git",

src/lib/Awards/Awards.svelte

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<script>
2-
import {cleanName, gotoManager} from '$lib/utils/helper';
3-
export let podium, currentManagers;
2+
import { gotoManager } from '$lib/utils/helper';
3+
import { getAvatarFromTeamManagers, getNestedTeamNamesFromTeamManagers } from '$lib/utils/helperFunctions/universalFunctions';
4+
export let podium, leagueTeamManagers;
45
56
const { year, champion, second, third, divisions, toilet } = podium;
6-
7-
const getNames = (name, rosterID) => {
8-
if(cleanName(name) != cleanName(currentManagers[rosterID].name)) {
9-
return `${name}<div class="curOwner">(${currentManagers[rosterID].name})</div>`;
10-
}
11-
return name;
12-
}
137
</script>
148

159
<style>
@@ -340,15 +334,15 @@
340334
<img src="./podium.png" class="podiumImage" alt="podium" />
341335

342336
<!-- champs -->
343-
<img src="{champion.avatar}" class="first champ clickable" on:click={() => gotoManager(champion.rosterID)} alt="champion" />
337+
<img src="{getAvatarFromTeamManagers(leagueTeamManagers, champion, year)}" class="first champ clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: champion})} alt="champion" />
344338
<img src="./laurel.png" class="laurel" alt="laurel" />
345-
<span class="label firstLabel clickable" on:click={() => gotoManager(champion.rosterID)}>{@html getNames(champion.name, champion.rosterID)}</span>
339+
<span class="label firstLabel clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: champion})}>{@html getNestedTeamNamesFromTeamManagers(leagueTeamManagers, year, champion)}</span>
346340

347-
<img src="{second.avatar}" class="second champ clickable" on:click={() => gotoManager(second.rosterID)} alt="2nd" />
348-
<span class="label secondLabel clickable" on:click={() => gotoManager(second.rosterID)}>{@html getNames(second.name, second.rosterID)}</span>
341+
<img src="{getAvatarFromTeamManagers(leagueTeamManagers, second, year)}" class="second champ clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: second})} alt="2nd" />
342+
<span class="label secondLabel clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: second})}>{@html getNestedTeamNamesFromTeamManagers(leagueTeamManagers, year, second)}</span>
349343

350-
<img src="{third.avatar}" class="third champ clickable" on:click={() => gotoManager(third.rosterID)} alt="3rd" />
351-
<span class="label thirdLabel clickable" on:click={() => gotoManager(third.rosterID)}>{@html getNames(third.name, third.rosterID)}</span>
344+
<img src="{getAvatarFromTeamManagers(leagueTeamManagers, third, year)}" class="third champ clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: third})} alt="3rd" />
345+
<span class="label thirdLabel clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: third})}>{@html getNestedTeamNamesFromTeamManagers(leagueTeamManagers, year, third)}</span>
352346
</div>
353347
<div class="divisions">
354348
{#each divisions as division}
@@ -360,10 +354,10 @@
360354
<h6>Regular Season Champion</h6>
361355
{/if}
362356
<div class="leaderBlock">
363-
<img src="{division.manager.avatar}" class="divisionLeader clickable" on:click={() => gotoManager(division.manager.rosterID)} alt="{division.name} champion" />
357+
<img src="{getAvatarFromTeamManagers(leagueTeamManagers, division.rosterID, year)}" class="divisionLeader clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: division.rosterID})} alt="{division.name} champion" />
364358
<img src="./medal.png" class="medal" alt="champion" />
365359
</div>
366-
<span class="genLabel clickable" on:click={() => gotoManager(division.manager.rosterID)}>{@html getNames(division.manager.name, division.manager.rosterID)}</span>
360+
<span class="genLabel clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: division.rosterID})}>{@html getNestedTeamNamesFromTeamManagers(leagueTeamManagers, year, division.rosterID)}</span>
367361
</div>
368362
{/if}
369363
{/each}
@@ -376,10 +370,10 @@
376370
<img src="./toilet-banner.png" class="toilet-banner" alt="The Toilet Bowl" />
377371

378372
<div class="toiletBowl">
379-
<img src="{toilet.avatar}" class="toiletWinner clickable" on:click={() => gotoManager(toilet.rosterID)} alt="toilet bowl winner" />
373+
<img src="{getAvatarFromTeamManagers(leagueTeamManagers, toilet, year)}" class="toiletWinner clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: toilet})} alt="toilet bowl winner" />
380374
<img src="./toilet-bowl-2.png" class="toilet" alt="toilet bowl" />
381375
</div>
382-
<span class="genLabel clickable" on:click={() => gotoManager(toilet.rosterID)}>{@html getNames(toilet.name, toilet.rosterID)}</span>
376+
<span class="genLabel clickable" on:click={() => gotoManager({leagueTeamManagers, rosterID: toilet})}>{@html getNestedTeamNamesFromTeamManagers(leagueTeamManagers, year, toilet)}</span>
383377
</div>
384378
{/if}
385379
</div>

src/lib/Bar.svelte

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<script>
2+
import { getAvatarFromTeamManagers, getTeamNameFromTeamManagers, gotoManager, round } from "./utils/helperFunctions/universalFunctions";
3+
4+
5+
export let leagueTeamManagers, stat, label, xMin, xMax, secondStat, managerID, rosterID, color, year;
6+
7+
$: user = managerID ? leagueTeamManagers.users[managerID] : null;
8+
</script>
9+
10+
<style>
11+
:global(.opacity) {
12+
opacity: 0.3;
13+
}
14+
15+
.barParent {
16+
position: relative;
17+
margin-bottom: -10px;
18+
height: 76px;
19+
}
20+
21+
.managerName {
22+
position: absolute;
23+
top: 0;
24+
left: 80px;
25+
}
26+
27+
.teamAvatar {
28+
position: absolute;
29+
left: 20px;
30+
top: 0;
31+
bottom: 0;
32+
height: 40px;
33+
margin: auto;
34+
border-radius: 50%;
35+
border: 2px solid;
36+
z-index: 14;
37+
background-color: #fff;
38+
}
39+
40+
.statBars {
41+
display: flex;
42+
margin: 0 auto;
43+
}
44+
45+
.leftSpacer {
46+
width: 40px;
47+
height: 1px;
48+
display: inline-block;
49+
}
50+
51+
.rightSpacer {
52+
width: 20px;
53+
height: 1px;
54+
display: inline-block;
55+
}
56+
57+
.bars {
58+
flex-grow: 2;
59+
position: relative;
60+
}
61+
62+
.bar {
63+
height: 1.8em;
64+
border-radius: 0 0.9em 0.9em 0;
65+
z-index: 10;
66+
}
67+
68+
.secondBar {
69+
position: absolute;
70+
top: 0;
71+
z-index: 11;
72+
left: 0;
73+
}
74+
75+
.barLabel {
76+
z-index: 12;
77+
vertical-align: text-top;
78+
margin-left: 40px;
79+
}
80+
81+
.vCenter {
82+
display: block;
83+
height: 1.8em;
84+
position: absolute;
85+
width: 100%;
86+
top: 0;
87+
bottom: 0;
88+
margin: auto 0;
89+
}
90+
91+
.clickable {
92+
cursor: pointer;
93+
}
94+
95+
@media (max-width: 600px) {
96+
.barParent {
97+
/* margin-bottom: -10px; */
98+
height: 57px;
99+
}
100+
.managerName {
101+
left: 60px;
102+
font-size: 0.8em;
103+
}
104+
.teamAvatar {
105+
left: 10px;
106+
height: 30px;
107+
}
108+
.barLabel {
109+
margin-left: 30px;
110+
vertical-align: middle;
111+
font-size: 0.8em;
112+
}
113+
.leftSpacer {
114+
width: 30px;
115+
}
116+
.rightSpacer {
117+
width: 10px;
118+
}
119+
.bar {
120+
height: 1.2em;
121+
border-radius: 0 0.6em 0.6em 0;
122+
}
123+
.vCenter {
124+
height: 1.2em;
125+
}
126+
}
127+
</style>
128+
129+
<div class="barParent">
130+
<img alt="team avatar" on:click={() => gotoManager({leagueTeamManagers, managerID, rosterID})} style="border-color: var({color});" class="teamAvatar clickable" src="{user ? `https://sleepercdn.com/avatars/thumbs/${user.avatar}` : getAvatarFromTeamManagers(leagueTeamManagers, rosterID, year)}" />
131+
<span class="managerName clickable" on:click={() => gotoManager({leagueTeamManagers, managerID, rosterID})}>
132+
{#if user}
133+
{user.display_name}
134+
{:else if rosterID}
135+
{getTeamNameFromTeamManagers(leagueTeamManagers, rosterID, year)}
136+
{/if}
137+
</span>
138+
<div class="vCenter">
139+
<div class="statBars">
140+
<div class="leftSpacer" />
141+
<div class="bars">
142+
<div class="bar{!secondStat ? '' : ' opacity'}" style="background-color: var({color}); width: {(stat - xMin) / (xMax - xMin == 0 ? 1 : (xMax - xMin)) * 100}%;">
143+
{#if !secondStat}
144+
<span class="barLabel">{stat}{label}</span>
145+
{/if}
146+
</div>
147+
{#if secondStat}
148+
<div class="bar secondBar" style="background-color: var({color}); width: {(secondStat - xMin) / (xMax - xMin == 0 ? 1 : (xMax - xMin)) * 100}%;">
149+
<span class="barLabel">{secondStat}&nbsp;&nbsp;of&nbsp;&nbsp;{stat}&nbsp;&nbsp;({round(secondStat/stat*100)}%)</span>
150+
</div>
151+
{/if}
152+
</div>
153+
<div class="rightSpacer" />
154+
</div>
155+
</div>
156+
</div>

0 commit comments

Comments
 (0)