mirror of
https://github.com/ppy/osu
synced 2024-12-14 10:57:41 +00:00
Merge pull request #1573 from peppy/improve-user-ratings-calculations
Improve user ratings calculations to make more sense
This commit is contained in:
commit
18e313b8f2
@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
|
||||
public class BeatmapMetrics
|
||||
{
|
||||
/// <summary>
|
||||
/// Total vote counts of user ratings on a scale of 0..length.
|
||||
/// Total vote counts of user ratings on a scale of 0..10 where 0 is unused (probably will be fixed at API?).
|
||||
/// </summary>
|
||||
public IEnumerable<int> Ratings { get; set; }
|
||||
|
||||
|
@ -20,6 +20,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private const Easing easing = Easing.InOutCubic;
|
||||
|
||||
private float length;
|
||||
|
||||
/// <summary>
|
||||
/// Length of the bar, ranges from 0 to 1
|
||||
/// </summary>
|
||||
@ -134,4 +135,4 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Vertical = TopToBottom | BottomToTop,
|
||||
Horizontal = LeftToRight | RightToLeft,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,11 +29,17 @@ namespace osu.Game.Screens.Select.Details
|
||||
if (value == metrics) return;
|
||||
metrics = value;
|
||||
|
||||
var ratings = Metrics.Ratings.ToList();
|
||||
negativeRatings.Text = ratings.GetRange(0, ratings.Count / 2 + 1).Sum().ToString();
|
||||
positiveRatings.Text = ratings.GetRange(ratings.Count / 2 + 1, ratings.Count / 2).Sum().ToString();
|
||||
ratingsBar.Length = (float)ratings.GetRange(0, ratings.Count / 2 + 1).Sum() / ratings.Sum();
|
||||
graph.Values = Metrics.Ratings.Select(r => (float)r);
|
||||
const int rating_range = 10;
|
||||
|
||||
var ratings = Metrics.Ratings.ToList().GetRange(1, rating_range); // adjust for API returning weird empty data at 0.
|
||||
|
||||
var negativeCount = ratings.GetRange(0, rating_range / 2).Sum();
|
||||
var totalCount = ratings.Sum();
|
||||
|
||||
negativeRatings.Text = negativeCount.ToString();
|
||||
positiveRatings.Text = (totalCount - negativeCount).ToString();
|
||||
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
|
||||
graph.Values = ratings.GetRange(0, rating_range).Select(r => (float)r);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user