diff --git a/lib/status/services/status_history.dart b/lib/status/services/status_history.dart index 5ac372f63..d8756976b 100644 --- a/lib/status/services/status_history.dart +++ b/lib/status/services/status_history.dart @@ -9,7 +9,7 @@ import 'package:priobike/settings/services/settings.dart'; class StatusHistory with ChangeNotifier { /// The count of predictions in the last week. - Map weekPredictions = {}; + Map weekGoodPredictions = {}; /// The count of subscriptions in the last week. Map weekSubscriptions = {}; @@ -18,7 +18,7 @@ class StatusHistory with ChangeNotifier { Map weekPercentages = {}; /// The count of predictions in the last day. - Map dayPredictions = {}; + Map dayGoodPredictions = {}; /// The count of subscriptions in the last day. Map daySubscriptions = {}; @@ -39,12 +39,12 @@ class StatusHistory with ChangeNotifier { /// Parses the data from the json response. List parseData(dynamic json) { - final Map predictions = {}; + final Map goodPredictions = {}; final Map subscriptions = {}; final Map percentages = {}; double maxSubscriptions = 0; - const predictionsKey = "average_prediction_service_predictions_count_total"; + const predictionsKey = "prediction_service_good_prediction_total"; const subscriptionsKey = "prediction_service_subscription_count_total"; // Parse into maps and get max number of subscriptions. @@ -52,7 +52,7 @@ class StatusHistory with ChangeNotifier { final predictionValue = entry.value.toDouble(); final double timestamp = double.parse(entry.key); - predictions[timestamp] = predictionValue; + goodPredictions[timestamp] = predictionValue; subscriptions[timestamp] = json[subscriptionsKey][entry.key].toDouble(); if (subscriptions[timestamp]! > maxSubscriptions) { maxSubscriptions = subscriptions[timestamp]!; @@ -60,7 +60,7 @@ class StatusHistory with ChangeNotifier { } // Calculate percentages. - for (final entry in predictions.entries) { + for (final entry in goodPredictions.entries) { if (maxSubscriptions == 0) { percentages[entry.key] = 0; continue; @@ -69,7 +69,7 @@ class StatusHistory with ChangeNotifier { percentages[entry.key] = percentage > 1 ? 1 : percentage; } - return [predictions, subscriptions, percentages]; + return [goodPredictions, subscriptions, percentages]; } /// Fetches the status history data from priobike-prediction-monitor. @@ -109,11 +109,11 @@ class StatusHistory with ChangeNotifier { final jsonWeek = jsonDecode(responseWeek.body); final dayData = parseData(jsonDay); - dayPredictions = dayData[0]; + dayGoodPredictions = dayData[0]; daySubscriptions = dayData[1]; dayPercentages = dayData[2]; final weekData = parseData(jsonWeek); - weekPredictions = weekData[0]; + weekGoodPredictions = weekData[0]; weekSubscriptions = weekData[1]; weekPercentages = weekData[2]; @@ -131,10 +131,10 @@ class StatusHistory with ChangeNotifier { /// Reset the status. Future reset() async { - weekPredictions = {}; + weekGoodPredictions = {}; weekSubscriptions = {}; weekPercentages = {}; - dayPredictions = {}; + dayGoodPredictions = {}; daySubscriptions = {}; dayPercentages = {}; isLoading = false;