1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 13:37:51 +08:00

Merge pull request #1588 from huoyaoyuan/no-maps

Fix user rating metrics when no data available
This commit is contained in:
Dean Herbert 2017-11-27 02:32:03 +09:00 committed by GitHub
commit 96aafd0ca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,15 +31,15 @@ namespace osu.Game.Screens.Select.Details
const int rating_range = 10; const int rating_range = 10;
var ratings = Metrics.Ratings.ToList().GetRange(1, rating_range); // adjust for API returning weird empty data at 0. var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
var negativeCount = ratings.GetRange(0, rating_range / 2).Sum(); var negativeCount = ratings.Take(rating_range / 2).Sum();
var totalCount = ratings.Sum(); var totalCount = ratings.Sum();
negativeRatings.Text = negativeCount.ToString(); negativeRatings.Text = negativeCount.ToString();
positiveRatings.Text = (totalCount - negativeCount).ToString(); positiveRatings.Text = (totalCount - negativeCount).ToString();
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount; ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
graph.Values = ratings.GetRange(0, rating_range).Select(r => (float)r); graph.Values = ratings.Take(rating_range).Select(r => (float)r);
} }
} }