diff --git a/Server/Application.cpp b/Server/Application.cpp index 9b4be81..f9115e3 100644 --- a/Server/Application.cpp +++ b/Server/Application.cpp @@ -163,7 +163,7 @@ Application::Application(const std::string &path) } database->add(std::move(record)); } - + Wt::Dbo::Transaction transaction(*database); boost::json::object reply; reply["page_view_count"] = database->query("SELECT COUNT(*) FROM visitor_record WHERE url = ?").bind(std::string(url)); reply["unique_visitor_count"] = database->query("SELECT COUNT(DISTINCT visitor_uuid) FROM visitor_record WHERE url = ?").bind(std::string(url)); @@ -195,6 +195,7 @@ Application::Application(const std::string &path) } } auto database = Database::session(); + Wt::Dbo::Transaction transaction(*database); Wt::Dbo::collection> query = database->query>("SELECT url, COUNT(*) as count FROM visitor_record GROUP BY url ORDER BY count DESC LIMIT ?").bind(size); boost::json::array reply; for (auto &[url, count] : query) { @@ -229,6 +230,7 @@ Application::Application(const std::string &path) } } auto database = Database::session(); + Wt::Dbo::Transaction transaction(*database); using Reslut = std::tuple; Wt::Dbo::collection query = database->query("SELECT url, MAX(time) FROM visitor_record GROUP BY url ORDER BY MAX(time) DESC LIMIT ?").bind(size); boost::json::array reply;