Added ratio back in, and empty stats Map
This commit is contained in:
parent
5c056fa101
commit
a127691f65
1 changed files with 23 additions and 4 deletions
|
@ -125,34 +125,53 @@ class PracticeDatabase {
|
||||||
getStats();
|
getStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO test the database
|
||||||
static Future<Map<String, dynamic>> getStats() async {
|
static Future<Map<String, dynamic>> getStats() async {
|
||||||
var db = await getDatabase();
|
var db = await getDatabase();
|
||||||
List<Map<String, dynamic>> answers = await db.rawQuery('''
|
List<Map<String, dynamic>> answers = await db.rawQuery('''
|
||||||
SELECT
|
SELECT
|
||||||
|
"All" AS range,
|
||||||
type,
|
type,
|
||||||
correct,
|
correct,
|
||||||
incorrect,
|
incorrect,
|
||||||
total
|
total,
|
||||||
|
correct / total AS ratio
|
||||||
FROM
|
FROM
|
||||||
AnswersCorrectByTypeViewAll
|
AnswersCorrectByTypeViewAll
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
|
"7d" AS range,
|
||||||
type,
|
type,
|
||||||
correct,
|
correct,
|
||||||
incorrect,
|
incorrect,
|
||||||
total
|
total,
|
||||||
|
correct / total AS ratio
|
||||||
FROM
|
FROM
|
||||||
AnswersCorrectByTypeView7d
|
AnswersCorrectByTypeView7d
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
|
"30d" AS range,
|
||||||
type,
|
type,
|
||||||
correct,
|
correct,
|
||||||
incorrect,
|
incorrect,
|
||||||
total
|
total,
|
||||||
|
correct / total AS ratio
|
||||||
FROM
|
FROM
|
||||||
AnswersCorrectByTypeView30d;
|
AnswersCorrectByTypeView30d;
|
||||||
''');
|
''');
|
||||||
print(answers);
|
print(answers);
|
||||||
print("something else");
|
var stats = getEmtpyStats();
|
||||||
|
|
||||||
|
print(stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Map<String, int> getEmtpyStats(){
|
||||||
|
Map<String, int> emptyStats = Map<String, int>();
|
||||||
|
["All", "30d", "7d"].forEach((range) => {
|
||||||
|
PracticeType.values.forEach((type) {
|
||||||
|
emptyStats["$range ${type.toString().split(".").last}"] = 0;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
return emptyStats;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue