From a127691f6568b7d26758b7883d4cc8cb7cf97467 Mon Sep 17 00:00:00 2001 From: BroodjeAap Date: Tue, 10 Nov 2020 17:33:27 +0100 Subject: [PATCH] Added ratio back in, and empty stats Map --- lib/pages/practice/PracticeDatabase.dart | 27 ++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/pages/practice/PracticeDatabase.dart b/lib/pages/practice/PracticeDatabase.dart index 7cd4789..eab4738 100644 --- a/lib/pages/practice/PracticeDatabase.dart +++ b/lib/pages/practice/PracticeDatabase.dart @@ -125,34 +125,53 @@ class PracticeDatabase { getStats(); } + // TODO test the database static Future> getStats() async { var db = await getDatabase(); List> answers = await db.rawQuery(''' SELECT + "All" AS range, type, correct, incorrect, - total + total, + correct / total AS ratio FROM AnswersCorrectByTypeViewAll UNION ALL SELECT + "7d" AS range, type, correct, incorrect, - total + total, + correct / total AS ratio FROM AnswersCorrectByTypeView7d UNION ALL SELECT + "30d" AS range, type, correct, incorrect, - total + total, + correct / total AS ratio FROM AnswersCorrectByTypeView30d; '''); print(answers); - print("something else"); + var stats = getEmtpyStats(); + + print(stats); + } + + static Map getEmtpyStats(){ + Map emptyStats = Map(); + ["All", "30d", "7d"].forEach((range) => { + PracticeType.values.forEach((type) { + emptyStats["$range ${type.toString().split(".").last}"] = 0; + }) + }); + return emptyStats; } } \ No newline at end of file