Skip to content

Conversation

@willmullinthomas
Copy link
Contributor

Why

Monday.com Ticket

What benefit does this bring to the end user? Or, what benefit does this bring to developers working in the codebase?

Connecting the leaderboard routes populates the leaderboard objects on the volunteer and teams pages with our data, allowing the user to see how who has logged the most trees

This PR

Describe the changes required and any implementation choices you made to give context to reviewers.

Some of the features looked like they could be abstracted, such as the actions and a lot of the types that the leaderboards use. These are in the actions.ts file and types.ts file in the components/leaderboard/ducks directory. The other ducks files are in the respective container directories for the volunteer and teams leaderboards.

One of the features of the leaderboard pages is the ability to view the best volunteers/teams of the last week/month/year/all-time. Each of these possible time scales requires a different object in the store and each has its own reducer. I think it's possible that a ton of the code here can be abstracted, however I was having a hard time doing so.

Screenshots

Provide screenshots of any new components, styling changes, or pages.

Verification Steps

What steps did you take to verify your changes work? These should be clear enough for someone to be able to clone the branch and follow the steps themselves.

Unfortunately, it turns out that the axios library we are using cannot accept arguments in request bodies for get requests. This means we are unable to test that the routes pull in data properly.

@willmullinthomas willmullinthomas requested review from a team, 796RCP92VZ, florisdobber, jackblanc, justinkonecny and liammoyn and removed request for a team January 25, 2021 00:48
@willmullinthomas willmullinthomas requested review from a team and removed request for justinkonecny January 25, 2021 03:26
Copy link
Member

@florisdobber florisdobber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will review this in more detail when the back end is fixed. Should be soon

Copy link

@liammoyn liammoyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is our approach that we'll call the leaderboard route multiple times for each timeframe when the user loads the page? It would probably be better to only be making the call once the user actually selects a particular timeframe so that we load faster and have less data overhead

tabs={[weeklyTab, monthlyTab, yearlyTab, allTimeTab]}
itemsPerPage={4}
/>
)}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have some way of displaying an error if one of the calls fails right?

src/store.ts Outdated
teamLeaderboardWeeklyState: TeamLeaderboardWeeklyReducerState;
teamLeaderboardMonthlyState: TeamLeaderboardMonthlyReducerState;
teamLeaderboardYearlyState: TeamLeaderboardYearlyReducerState;
teamLeaderboardAllTimeState: TeamLeaderboardAllTimeReducerState;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like some nesting would be helpful, having a leaderboardState that then contains user and team states

Copy link
Member

@jackblanc jackblanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks incredible, thank you for doing this, and I'm sorry I didn't get you a review any sooner.

This is mostly there, but I think there's a lot of extra code we won't end up needing.

The main idea I have in this review is that we want to simplify the reducers state and remove usages of React state. We don't need a separate reducer for each time frame of each leaderboard. If we want to store all four time frames in state, we can make four pieces of state in each reducer. Personally, I think we're better off simplifying this by simply having one reducer per leaderboard, which can be called to fetch T - X days for any X.

Let me know if any of this is confusing, happy to chat during office hours today.

@jackblanc jackblanc marked this pull request as ready for review February 2, 2021 16:27
@willmullinthomas
Copy link
Contributor Author

Condensed a lot of the redux stuff so there is now only 1 item in the store for each of the leaderboards. Also moved the logic for converting LeaderboardItems to TabItems in order to avoid having a redundant React state

<LinkCard
text="Team Leaderboard"
path="/team-leaderboard"
background="img4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is img4? Where is it stored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the linkcard, folder. I didn't make this component, I just added the path variable and prettier changed the indenting

Comment on lines +46 to +47
userLeaderboardState: userLeaderboardReducer,
teamLeaderboardState: teamLeaderboardReducer,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@jackblanc jackblanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks much better! Left a few more questions, please update the API client to hit the API and verify that it can connect properly, then I'll give a final review.

@jackblanc
Copy link
Member

Screen Shot 2021-02-15 at 1 16 38 PM
The issues with checks are valid and must be fixed.

}
};
store.subscribe(listener);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere? I got an error when it wasn't commented out

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it is, I'll look into this right now it came up yesterday for me too

Copy link
Member

@jackblanc jackblanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Awesome work iterating on this

jackblanc added a commit that referenced this pull request Feb 18, 2021
…-localstorage

Implement Refresh and State Persistence
@jackblanc
Copy link
Member

@willmt80 let me know if you want help resolving these merge conflicts

@willmullinthomas willmullinthomas merged commit 9a82901 into master Feb 20, 2021
@chromium-52 chromium-52 deleted the LeaderboardRoutes branch December 14, 2022 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants