// Load the events, splitting them into matches as we go.
std::map<int, QJsonArray *> events_per_match;
sqlite3_stmt *stmt;
- int ret = sqlite3_prepare_v2(db, "SELECT match, t, player, type FROM event ORDER BY t", -1, &stmt, 0);
+ int ret = sqlite3_prepare_v2(db, "SELECT match, t, player, formation, type FROM event ORDER BY t", -1, &stmt, 0);
if (ret != SQLITE_OK) {
fprintf(stderr, "SELECT prepare: %s\n", sqlite3_errmsg(db));
abort();
} else {
e.insert("player", QJsonValue()); // null
}
- e.insert("type", (const char *)sqlite3_column_text(stmt, 3));
+ if (sqlite3_column_type(stmt, 3) == SQLITE_INTEGER) {
+ e.insert("formation", sqlite3_column_int(stmt, 3));
+ } else {
+ e.insert("formation", QJsonValue()); // null
+ }
+ e.insert("type", (const char *)sqlite3_column_text(stmt, 4));
events_per_match[match]->push_back(std::move(e));
} else if (ret == SQLITE_DONE) {
break;