diff --git a/frontend/src/app/modules/matches/matches-computations.js b/frontend/src/app/modules/matches/matches-computations.js
index 74d70dd1..4eff61d5 100644
--- a/frontend/src/app/modules/matches/matches-computations.js
+++ b/frontend/src/app/modules/matches/matches-computations.js
@@ -41,27 +41,37 @@ export const plotRatingHistory = (userMatches, userId, initialRating) => {
))
}
-export const computeLongestWinStreak = (userId, userMatches) => {
+export const computeStreaks = (userId, userMatches) => {
const initialState = {
- longest: 0,
- current: 0,
+ longestWinStreak: 0,
+ currentWinStreak: 0,
+ highestEloGainStreak: 0,
+ currentEloGainStreak: 0,
}
- return userMatches.reduce((state, match) => {
+ const reversedMatches = [...userMatches].reverse()
+
+ return reversedMatches.reduce((state, match) => {
if (didUserWin(userId, match)) {
- const current = state.current + 1
- const longest = Math.max(current, state.longest)
+ const currentWinStreak = state.currentWinStreak + 1
+ const longestWinStreak = Math.max(currentWinStreak, state.longestWinStreak)
+ const currentEloGainStreak = state.currentEloGainStreak + match.winningTeamRatingChange
+ const highestEloGainStreak = Math.max(currentEloGainStreak, state.highestEloGainStreak)
return {
- current,
- longest,
+ currentWinStreak,
+ longestWinStreak,
+ currentEloGainStreak,
+ highestEloGainStreak,
}
} else {
return {
- longest: state.longest,
- current: 0,
+ longestWinStreak: state.longestWinStreak,
+ currentWinStreak: 0,
+ highestEloGainStreak: state.highestEloGainStreak,
+ currentEloGainStreak: 0,
}
}
- }, initialState).longest
+ }, initialState)
}
export const computeWinRatio = (userId, userMatches) => {
diff --git a/frontend/src/app/modules/matches/matches-selectors.js b/frontend/src/app/modules/matches/matches-selectors.js
index a7e6b1ec..8c3d608e 100644
--- a/frontend/src/app/modules/matches/matches-selectors.js
+++ b/frontend/src/app/modules/matches/matches-selectors.js
@@ -1,6 +1,6 @@
import { createSelector } from 'reselect'
import {
- computeLongestWinStreak,
+ computeStreaks,
computeWinRatio,
generateMatchRatingChanges,
plotRatingHistory,
@@ -39,7 +39,7 @@ const getLastMatchesForUser = createSelector(
const generateStatisticsForUser = (userId, userMatches) => ({
matchChanges: generateMatchRatingChanges(userId, userMatches),
- longestStreak: computeLongestWinStreak(userId, userMatches),
+ streaks: computeStreaks(userId, userMatches),
winRatio: computeWinRatio(userId, userMatches),
totalMatches: userMatches.length,
})
diff --git a/frontend/src/app/modules/root/root-reducer.js b/frontend/src/app/modules/root/root-reducer.js
index 1caca503..c527f75d 100644
--- a/frontend/src/app/modules/root/root-reducer.js
+++ b/frontend/src/app/modules/root/root-reducer.js
@@ -18,7 +18,7 @@ const initialState = {
const usersLoaded = (state, { users }) => ({
...state,
- users
+ users,
})
const updateUsersStatus = (state, { status }) => ({
diff --git a/frontend/src/app/pages/Profile/index.js b/frontend/src/app/pages/Profile/index.js
index 6d9c0d28..7d364fe7 100644
--- a/frontend/src/app/pages/Profile/index.js
+++ b/frontend/src/app/pages/Profile/index.js
@@ -18,7 +18,17 @@ class ProfileComponent extends Component {
const {
user: { name, rating, id },
- statistics: { totalMatches, winRatio, longestStreak, matchChanges },
+ statistics: {
+ totalMatches,
+ winRatio,
+ matchChanges,
+ streaks: {
+ currentWinStreak,
+ longestWinStreak,
+ currentEloGainStreak,
+ highestEloGainStreak,
+ },
+ },
} = this.props
return (
@@ -28,7 +38,10 @@ class ProfileComponent extends Component {
Matches: {totalMatches}
Win Rate: {(winRatio * 100).toFixed(2)}%
- Win Streak: {longestStreak}
+ Longest Win Streak: {longestWinStreak}
+ Current Win Streak: {currentWinStreak}
+ Highest Elo Gain Streak: {highestEloGainStreak}
+ Current Elo Gain Streak: {currentEloGainStreak}