private void CreateHistorySection(List <Workout> workouts, LinearLayout pointsHistoryVerticalLayout, LinearLayout pointsAggregatesVerticalLayout) { var pointsToday = _circuitLogService.SelectRunningWeeksLogsFromWorkouts().Sum(x => x.GetPoints()); var pointsYesterday = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(customReferencePoint: DateTime.Now.AddDays(-1)).Sum(x => x.GetPoints()); var pointsTwoDaysAgo = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(customReferencePoint: DateTime.Now.AddDays(-2)).Sum(x => x.GetPoints()); var pointsThreeDaysAgo = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(customReferencePoint: DateTime.Now.AddDays(-3)).Sum(x => x.GetPoints()); var pointsFourDaysAgo = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(customReferencePoint: DateTime.Now.AddDays(-4)).Sum(x => x.GetPoints()); var pointsFiveDaysAgo = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(customReferencePoint: DateTime.Now.AddDays(-5)).Sum(x => x.GetPoints()); var pointsSixDaysAgo = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(customReferencePoint: DateTime.Now.AddDays(-6)).Sum(x => x.GetPoints()); var pointsAWeekAgo = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(customReferencePoint: DateTime.Now.AddDays(-7)).Sum(x => x.GetPoints()); var listOfAverages = new List <double> { pointsToday, pointsYesterday, pointsTwoDaysAgo, pointsThreeDaysAgo, pointsFourDaysAgo, pointsFiveDaysAgo, pointsSixDaysAgo, pointsAWeekAgo }; var best = listOfAverages.Max(); var min = listOfAverages.Min(); var avg = listOfAverages.Average(); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsAWeekAgo, best, min); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsSixDaysAgo, best, min); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsFiveDaysAgo, best, min); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsFourDaysAgo, best, min); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsThreeDaysAgo, best, min); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsTwoDaysAgo, best, min); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsYesterday, best, min); AddPointsHistoryForDay(pointsHistoryVerticalLayout, pointsToday, best, min); pointsAggregatesVerticalLayout.AddView(new TextView(pointsAggregatesVerticalLayout.Context) { Text = $"Average: {avg}" }); }
public void Should_return_data_within_the_last_7_days_by_default() { var last7DaysData = _service.SelectRunningWeeksLogsFromWorkouts(); Assert.AreEqual(2, last7DaysData.Count()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var circuitLogRepository = new CircuitLogRepository(); var meditationLogRepository = new MeditationLogRepository(); var waterLogRepository = new WaterLogRepository(); var physioCircuitWorkout = new PhysioCircuit(); physioCircuitWorkout.LogList.AddRange(circuitLogRepository.Get()); _circuitLogService = new CircuitLogService(circuitLogRepository); var workouts = new List <Workout>() { physioCircuitWorkout }; var meditations = meditationLogRepository.GetForWeek().ToList(); var waterLogs = waterLogRepository.GetForWeek().ToList(); var layout = new LinearLayout(this) { Orientation = Orientation.Vertical }; var table = BuildTableLayoutFromWorkouts(workouts, meditations, waterLogs, this); layout.AddView(table); var reportsHorizontalLayout = new LinearLayout(layout.Context) { Orientation = Orientation.Vertical }; var currentWeekStatsVerticalLayout = new LinearLayout(layout.Context) { Orientation = Orientation.Vertical }; var pointsHistoryVerticalLayout = new LinearLayout(layout.Context) { Orientation = Orientation.Horizontal }; var pointsAggregatesVerticalLayout = new LinearLayout(layout.Context) { Orientation = Orientation.Vertical }; var currentLevelVerticalLayout = new LinearLayout(layout.Context) { Orientation = Orientation.Vertical }; layout.AddView(reportsHorizontalLayout); reportsHorizontalLayout.AddView(currentWeekStatsVerticalLayout); reportsHorizontalLayout.AddView(pointsHistoryVerticalLayout); reportsHorizontalLayout.AddView(pointsAggregatesVerticalLayout); reportsHorizontalLayout.AddView(currentLevelVerticalLayout); currentWeekStatsVerticalLayout.SetPadding(5, 5, 5, 5); pointsHistoryVerticalLayout.SetPadding(5, 5, 5, 5); pointsAggregatesVerticalLayout.SetPadding(5, 5, 5, 5); CreateCurrentWeekStatsSection(workouts, currentWeekStatsVerticalLayout); CreateHistorySection(workouts, pointsHistoryVerticalLayout, pointsAggregatesVerticalLayout); var currentLevelText = new TextView(this) { Text = "Level " + Workout.CURRENT_LEVEL.ToString() }; currentLevelText.SetPadding(5, 5, 5, 5); currentLevelText.SetTextColor(new Color(255, 255, 255)); currentLevelVerticalLayout.AddView(currentLevelText); currentLevelVerticalLayout.AddView ( BuildProgressBarChart ( steps: new int[] { 12, 15, 22 }, goal: 40, title: "Continuous Pushups", icon: Resource.Drawable.Pushups ) ); var crunchesPerDayData = new List <int>(); for (int i = 0; i < 7; i++) { var referenceDate = DateTime.Now.AddDays(-i); var logs = _circuitLogService.SelectRunningWeeksLogsFromWorkouts(referenceDate); var circuit = new PhysioCircuit(logs); var crunchesPerformed = circuit.GetTotalCrunchesPerformed(); var averagePerDay = crunchesPerformed / 7; crunchesPerDayData.Add(averagePerDay); } currentLevelVerticalLayout.AddView ( BuildProgressBarChart ( steps: crunchesPerDayData.ToArray(), goal: 200, title: "Crunches per day", icon: Resource.Drawable.Crunches ) ); currentLevelVerticalLayout.AddView ( BuildProgressBarChart ( steps: new int[] { 50, 60, 67, 68, 66, 63, 50 }, goal: 100, title: "Crunches in a minute", icon: Resource.Drawable.Crunches ) ); SetContentView(layout); }