From 064fe5fbadc4921f65f16206b52024a062f15bed Mon Sep 17 00:00:00 2001 From: Dario Date: Sun, 5 Jul 2020 10:50:46 +0200 Subject: [PATCH] update function to get clearer debug picture --- src/cpp/controller/User.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/cpp/controller/User.cpp b/src/cpp/controller/User.cpp index 3b43cfb90..273ae2350 100644 --- a/src/cpp/controller/User.cpp +++ b/src/cpp/controller/User.cpp @@ -321,22 +321,33 @@ namespace controller { auto session = cm->getConnection(CONNECTION_MYSQL_LOGIN_SERVER); Poco::Data::Statement select(session); std::vector> results; + int email_checked = 0; + int resend_count = 1; select << "select u.id, v.created from users as u " << "LEFT JOIN email_opt_in as v ON(u.id = v.user_id) " - << "where u.email_checked = 0 " - << "AND v.resend_count <= 1", Poco::Data::Keywords::into(results) + << "where u.email_checked = ? " + << "AND v.resend_count <= ?", Poco::Data::Keywords::use(email_checked), Poco::Data::Keywords::use(resend_count), Poco::Data::Keywords::into(results) ; - + int result_count = 0; try { + result_count = select.execute(); + } + catch (Poco::Exception& ex) { + em->addError(new ParamError(function_name, "mysql error by select", ex.displayText().data())); + em->sendErrorsAsEmail(); + //return -1; + } + printf("result_count: %d\n", result_count); + if (result_count > 0) { auto now = Poco::DateTime(); - select.execute(); + int count_scheduled_at_once = 0; int count_scheduled = 0; for (auto it = results.begin(); it != results.end(); it++) { auto user_id = it->get<0>(); auto created = it->get<1>(); - + auto age = now - created; // older than 7 days, schedule at once if (age.days() > 7) { @@ -351,13 +362,8 @@ namespace controller { count_scheduled++; } } - if(count_scheduled_at_once) printf("scheduled %d verification email resend at once\n", count_scheduled_at_once); - if(count_scheduled) printf("scheduled %d verification email resend in the next 7 days\n", count_scheduled); - } - catch (Poco::Exception& ex) { - em->addError(new ParamError(function_name, "mysql error by select", ex.displayText().data())); - em->sendErrorsAsEmail(); - return -1; + if (count_scheduled_at_once) printf("scheduled %d verification email resend at once\n", count_scheduled_at_once); + if (count_scheduled) printf("scheduled %d verification email resend in the next 7 days\n", count_scheduled); } return 0; }