Skip to content

Commit

Permalink
Fixing score (no displaying minus)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bazire HOUSSIN committed Oct 16, 2018
1 parent 0586ffb commit 5709d7b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/views/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Button from 'focus-components/components/button';

import eventServices from '@/services/event';
import FFSWebSocket from '@/utilities/web-socket';
import {isAdmin} from "@/utilities/check-rights";
import { isAdmin } from '@/utilities/check-rights';

const LineComponent = createReactClass({
displayName: 'ResultLineView',
Expand Down Expand Up @@ -99,7 +99,7 @@ class StatsView extends React.Component {

this.state.results
.forEach((arrRes, idx) => {
part['round' + (idx + 1)] = arrRes.filter(elt => elt.id === twitchId).reduce((acc, elt) => (elt.score || '?'), '?');
part['round' + (idx + 1)] = arrRes.filter(elt => elt.id === twitchId).reduce((acc, elt) => (Math.abs(elt.score) || '?'), '?');
});
part.total = this.state.results
.map((arrRes) => +((arrRes.find(elt => elt.id === twitchId) || {}).score || 0))
Expand All @@ -109,6 +109,8 @@ class StatsView extends React.Component {
.map((arrRes) => +((arrRes.find(elt => elt.id === twitchId) || {}).score || 1000))
.reduce((acc, score) => acc + score, 0);

part.total = Math.abs(part.total);

return part;
})
.sort((a, b) => a.hiddenTotal - b.hiddenTotal)
Expand All @@ -129,8 +131,8 @@ class StatsView extends React.Component {
if (isAdmin()) {
let results = this.buildResults();
results.shift();
results.forEach(({twitchId, rank}) => {
eventServices.updateUserRank({id: this.props.params.id, idUser: twitchId, rank: rank});
results.forEach(({ twitchId, rank }) => {
eventServices.updateUserRank({ id: this.props.params.id, idUser: twitchId, rank: rank });
});
}
};
Expand Down

0 comments on commit 5709d7b

Please sign in to comment.