-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: make profile data fetching consistent & add back correct puzzl…
…es played count
- Loading branch information
1 parent
9c484bd
commit cadaf22
Showing
5 changed files
with
49 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './profile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { buildUrl } from '../utils' | ||
|
||
export const getPlayerStats = async () => { | ||
const res = await fetch(buildUrl('auth/get_player_stats')) | ||
const data = await res.json() | ||
return { | ||
regularRating: data.play_elo as number, | ||
regularWins: data.play_won as number, | ||
regularDraws: data.play_drawn as number, | ||
regularGames: data.play_games_played as number, | ||
regularMax: data.play_elo_max as number, | ||
regularMin: data.play_elo_min as number, | ||
regularHours: data.play_game_time as number, | ||
|
||
handRating: data.hand_elo as number, | ||
handWins: data.hand_won as number, | ||
handDraws: data.hand_drawn as number, | ||
handGames: data.hand_games_played as number, | ||
handMax: data.hand_elo_max as number, | ||
handMin: data.hand_elo_min as number, | ||
handHours: data.hand_game_time as number, | ||
|
||
brainRating: data.brain_elo as number, | ||
brainWins: data.brain_won as number, | ||
brainDraws: data.brain_drawn as number, | ||
brainGames: data.brain_games_played as number, | ||
brainMax: data.brain_elo_max as number, | ||
brainMin: data.brain_elo_min as number, | ||
brainHours: data.brain_game_time as number, | ||
|
||
trainRating: data.puzzles_elo as number, | ||
trainCorrect: data.puzzles_correct as number, | ||
trainGames: Math.max(0, (data.puzzles_played as number) - 1), | ||
trainMax: data.puzzles_elo_max as number, | ||
trainMin: data.puzzles_elo_min as number, | ||
trainHours: data.puzzle_game_time as number, | ||
|
||
botNotRating: data.turing_elo as number, | ||
botNotCorrect: data.turing_guesses_correct as number, | ||
botNotWrong: data.turing_guesses_wrong as number, | ||
botNotMax: data.turing_elo_max as number, | ||
botNotMin: data.turing_elo_min as number, | ||
botNotHours: data.turing_game_time as number, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters