Skip to content

fix rating on member profile #4193

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/shared/components/ProfilePage/Stats/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class ProfileStats extends React.Component {
const subTrackSummary = getSummary(stats, track, subTrack) || [];
const subTrackDetails = getDetails(stats, track, subTrack) || [];
const ratingObj = subTrackSummary.filter(k => k.label === 'rating');
const trackHistory = getHistory(statsHistory, track, subTrack);
const latestTrackHistory = trackHistory.history.pop();
let subTrackRating = ratingObj && ratingObj[0] ? ratingObj[0].value : 0;
if (subTrackRating === 0 || !subTrackRating) { // if subtrack has no rating, pick default rating
subTrackRating = info.maxRating ? info.maxRating.rating : 0;
Expand Down Expand Up @@ -185,7 +187,7 @@ class ProfileStats extends React.Component {
className={label === 'rating' ? styles.rating : ''}
style={{ color: label === 'rating' ? getRatingColor(parseInt(value.replace(/\D/g, ''), 10)) : undefined }}
>
{value || '-'}
{(label === 'rating' && latestTrackHistory) ? latestTrackHistory.newRating : (value || '-')}
{label === 'rating' && <span styleName="square" style={{ backgroundColor: getRatingColor((parseInt(value.replace(/\D/g, ''), 10))) }} />}
</div>
)
Expand Down Expand Up @@ -230,7 +232,7 @@ class ProfileStats extends React.Component {
activeGraph === 'history'
? (
<HistoryGraph
history={getHistory(statsHistory, track, subTrack)}
history={trackHistory}
track={track}
subTrack={subTrack}
/>
Expand Down