getAllTrackedDonationsForAmountGraph method
Retrieve all tracked donations and convert them to a list of GraphAmountDataPoint objects. These will be used to plot the donation data on the donation graph
Implementation
Future<List<GraphAmountDataPoint>> getAllTrackedDonationsForAmountGraph() async {
await openMMDatabase();
int total = 0;
List<Map> maps = await db.query(tableTrackedDonations,
columns: [columnId, columnDateString, columnAmount, columnDonationProcessed],);
List<GraphAmountDataPoint> dataPoints = List<GraphAmountDataPoint>();
maps.forEach((element) {
TrackedDonation tracked = TrackedDonation.fromMap(element);
dataPoints.add(GraphAmountDataPoint(amount: tracked.amount, date: tracked.dateRecorded));
});
dataPoints.sort((a,b) => a.date.compareTo(b.date));
for(int i=0; i < dataPoints.length; i++){
total += dataPoints[i].amount;
dataPoints[i].amount = total;
print(total);
}
return dataPoints;
}