This commit is contained in:
parent
889faa4404
commit
a6553d3597
@ -163,7 +163,7 @@ Application::Application(const std::string &path)
|
|||||||
}
|
}
|
||||||
database->add(std::move(record));
|
database->add(std::move(record));
|
||||||
}
|
}
|
||||||
|
Wt::Dbo::Transaction transaction(*database);
|
||||||
boost::json::object reply;
|
boost::json::object reply;
|
||||||
reply["page_view_count"] = database->query<int>("SELECT COUNT(*) FROM visitor_record WHERE url = ?").bind(std::string(url));
|
reply["page_view_count"] = database->query<int>("SELECT COUNT(*) FROM visitor_record WHERE url = ?").bind(std::string(url));
|
||||||
reply["unique_visitor_count"] = database->query<int>("SELECT COUNT(DISTINCT visitor_uuid) FROM visitor_record WHERE url = ?").bind(std::string(url));
|
reply["unique_visitor_count"] = database->query<int>("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();
|
auto database = Database::session();
|
||||||
|
Wt::Dbo::Transaction transaction(*database);
|
||||||
Wt::Dbo::collection<std::tuple<std::string, int>> query = database->query<std::tuple<std::string, int>>("SELECT url, COUNT(*) as count FROM visitor_record GROUP BY url ORDER BY count DESC LIMIT ?").bind(size);
|
Wt::Dbo::collection<std::tuple<std::string, int>> query = database->query<std::tuple<std::string, int>>("SELECT url, COUNT(*) as count FROM visitor_record GROUP BY url ORDER BY count DESC LIMIT ?").bind(size);
|
||||||
boost::json::array reply;
|
boost::json::array reply;
|
||||||
for (auto &[url, count] : query) {
|
for (auto &[url, count] : query) {
|
||||||
@ -229,6 +230,7 @@ Application::Application(const std::string &path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto database = Database::session();
|
auto database = Database::session();
|
||||||
|
Wt::Dbo::Transaction transaction(*database);
|
||||||
using Reslut = std::tuple<std::string, system_clock::time_point>;
|
using Reslut = std::tuple<std::string, system_clock::time_point>;
|
||||||
Wt::Dbo::collection<Reslut> query = database->query<Reslut>("SELECT url, MAX(time) FROM visitor_record GROUP BY url ORDER BY MAX(time) DESC LIMIT ?").bind(size);
|
Wt::Dbo::collection<Reslut> query = database->query<Reslut>("SELECT url, MAX(time) FROM visitor_record GROUP BY url ORDER BY MAX(time) DESC LIMIT ?").bind(size);
|
||||||
boost::json::array reply;
|
boost::json::array reply;
|
||||||
|
Loading…
Reference in New Issue
Block a user