-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add achievement overview and leaderboard #5169
base: master
Are you sure you want to change the base?
Add achievement overview and leaderboard #5169
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
5300ead
to
6c8a446
Compare
b12fd87
to
4dd48c6
Compare
5174378
to
fa79b0f
Compare
fa79b0f
to
0b4fecf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good! I've left some suggestions, some nitpicks and some comments. We'll get this running real fast 😎
@@ -245,6 +245,7 @@ export const NotificationsFeed = { | |||
*/ | |||
export const User = { | |||
FETCH: generateStatuses('User.FETCH') as AAT, | |||
FETCH_LEADERBOARD: generateStatuses('User.FETCH') as AAT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid using the same status for different actions
export function fetchLeaderboardUsers() { | ||
return callAPI<PublicUser[]>({ | ||
types: User.FETCH_LEADERBOARD, | ||
endpoint: `/achievements/leaderboard/`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to declare method as GET
here
selectUserEntities, | ||
(userEntities) => { | ||
return Object.values(userEntities).filter( | ||
(user) => user.achievementScore != null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to do
(user) => !!user.achievementScore,
so that we catch undefined
and 0
as well as null
})); | ||
const columns: ColumnProps<RankedUser>[] = [ | ||
{ | ||
title: 'Posisjon', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to "Rang" or "Rangering"?
const allTrophies = Object.entries(AchievementsInfo).flatMap( | ||
([key, achievements]) => | ||
achievements.map((achievement, index) => ({ | ||
...achievement, | ||
identifier: key, | ||
level: index, | ||
})), | ||
); | ||
|
||
const filteredTrophies = allTrophies.filter((trophy) => { | ||
const rarity = trophy.rarity; | ||
const minRarity = | ||
query.min_rarity !== 'any' ? parseInt(query.min_rarity, 10) : 0; | ||
const maxRarity = | ||
query.max_rarity !== 'any' ? parseInt(query.max_rarity, 10) : Infinity; | ||
return rarity >= minRarity && rarity <= maxRarity; | ||
}); | ||
|
||
const sortedTrophies = [...filteredTrophies].sort((a, b) => { | ||
let comparison = 0; | ||
if (query.sort === 'rarity') comparison = a.rarity - b.rarity; | ||
if (query.sort === 'alphabetical') | ||
comparison = a.name.localeCompare(b.name); | ||
if (query.sort === 'hidden') | ||
comparison = a.hidden === b.hidden ? 0 : a.hidden ? -1 : 1; | ||
|
||
return query.sort_order === 'desc' ? -comparison : comparison; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we are explicitly storing each list?
I get that it's nice to divide clearly up into filtering and sorting, but it might be better to just define the filter and sorting lambda's instead and then do
const trophies =
Obejct.entries(Achievements)
.flatMap(flatMapper)
.filter(trophyFilter)
.sort(trophyComparator)
where flatMapper
, trophyFilter
, and trophyComparator
are just named lambdas:
const trophyFilter: (trophy: Trophy) => boolean = (trophy) => {
//...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An named lambda for the flatMapper
isn't really that important though
@@ -37,6 +38,7 @@ export const routerConfig: RouteObject[] = [ | |||
Component: AppRoute, | |||
children: [ | |||
{ index: true, Component: Frontpage }, | |||
{ path: 'achievements/*', children: achievementRoute }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: achievementsRoute
(with an s)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice feature, looks great!
Description
Adds achievement overview and leaderboard.
Result
If you've made visual changes, please check the boxes below and include images showing the changes. Descriptions are appreciated.
Caution
Make sure your images do not contain any real user information.
Testing
Please describe what and how the changes have been tested, and provide instructions to reproduce if necessary.
Resolves ... (either GitHub issue or Linear task)