public static void CreateDetailForGroup(StatisticsGroup group, int sort, string icon, string displayName, UserMeasurementUnitMetric metric) { var detail = new UserMeasurementUnitStatisticsDetail(metric) { Sort = sort, Icon = icon, DisplayDescription = displayName, Group = group }; group.Details.Add(detail); }
private static void FillStatistics(SegmentEffort segmentEffort) { StatisticsGroup current = new StatisticsGroup() { Name = "this effort", Sort = 0, Type = StatisticGroupType.Current }; StatisticsDetail movingTimeCurrent = new StatisticsDetail() { Sort = 0, Icon = "", DisplayDescription = "moving time", DisplayValue = $"{Helpers.Converters.SecToTimeConverter.Convert(segmentEffort.ElapsedTime, typeof(int), null, string.Empty)}", Group = current }; StatisticsDetail averageSpeedCurrent = new UserMeasurementUnitStatisticsDetail(segmentEffort.AverageSpeedMeasurementUnit) { Sort = 1, Icon = "", DisplayDescription = "average speed", Group = current }; StatisticsDetail averageHeartRateCurrent = new StatisticsDetail() { Sort = 2, Icon = "", DisplayDescription = "average heart rate", DisplayValue = $"{Math.Round(segmentEffort.AverageHeartrate)} bpm", Group = current }; StatisticsDetail maxHeartRateCurrent = new StatisticsDetail() { Sort = 3, Icon = "", DisplayDescription = "max heart rate", DisplayValue = $"{segmentEffort.MaxHeartrate} bpm", Group = current }; current.Details.Add(movingTimeCurrent); current.Details.Add(averageSpeedCurrent); current.Details.Add(averageHeartRateCurrent); current.Details.Add(maxHeartRateCurrent); segmentEffort.Statistics.Add(current); }
public void FillStatistics(SegmentEffort segmentEffort, Leaderboard leaderboard) { if (leaderboard != null) { var entry = (from element in leaderboard.Entries where element.AthleteId == segmentEffort.Athlete.Id select element).FirstOrDefault(); if (entry != null) { //TODO: Glenn - Verify SegmentViewModel - There we also retrieve the corresponding Segment for MAP info, maybe better we do it here in the Service?? ( Merge/Combine ) //TODO: Glenn - moved segment setting logic into GetLeaderboardFromServiceAsync //TODO: Glenn - each leaderboard entry should need a segment to calculate the averagespeed //entry.Segment = segmentEffort.Segment; StatisticsGroup pr = new StatisticsGroup() { Name = "personal record", Sort = 1, Type = StatisticGroupType.PR }; StatisticsDetail movingTimePR = new StatisticsDetail() { Sort = 0, Icon = "", DisplayDescription = "moving time", DisplayValue = $"{Helpers.Converters.SecToTimeConverter.Convert(entry.MovingTime, typeof (int), null, string.Empty)}", Group = pr }; StatisticsDetail averageSpeedPR = new UserMeasurementUnitStatisticsDetail(entry.AverageSpeedUserMeasurementUnit) { Sort = 1, Icon = "", DisplayDescription = "average speed", Group = pr }; StatisticsDetail averageHeartRatePR = new StatisticsDetail() { Sort = 2, Icon = "", DisplayDescription = "average heart rate", DisplayValue = $"{Math.Round(entry.AverageHeartrateDisplay)} bpm", Group = pr }; StatisticsDetail rankPR = new StatisticsDetail() { Sort = 2, Icon = "", DisplayDescription = "rank", DisplayValue = $"{entry.Rank}/{leaderboard.EntryCount}", Group = pr }; pr.Details.Add(movingTimePR); pr.Details.Add(averageSpeedPR); pr.Details.Add(averageHeartRatePR); pr.Details.Add(rankPR); segmentEffort.Statistics.Add(pr); } } }