created summary route

master
Matt Huntington 3 years ago
parent b147c8fdba
commit ed17204718

@ -21,20 +21,22 @@ int main()
driver = get_driver_instance();
con = driver->connect(getenv("DBURL"),getenv("DBUSER"),getenv("DBPWD"));
con->setSchema("timer_backend");
con->setSchema("practice");
stmt = con->createStatement();
CROW_ROUTE(app, "/seconds")([](){
CROW_ROUTE(app, "/summary")([](){
crow::json::wvalue entries;
ResultSet *res = stmt->executeQuery("SELECT * FROM sessions;");
ResultSet *res = stmt->executeQuery("SELECT * FROM summary ORDER BY chunks_practiced ASC;");
int i = 0;
while (res->next()) {
int id = res->getInt("id");
int seconds = res->getInt("seconds");
string created_at = res->getString("created_at");
entries[i] = {{"id", id}, {"seconds", seconds}, {"created_at", created_at}};
int category_id = res->getInt("category_id");
string category = res->getString("category");
string instrument = res->getString("instrument");
double chunks_practiced = res->getDouble("chunks_practiced");
int weight = res->getInt("weight");
entries[i] = {{"category_id", category_id}, {"category", category}, {"instrument", instrument}, {"chunks_practiced", chunks_practiced}, {"weight", weight}};
i++;
}

Loading…
Cancel
Save