|
@@ -6,6 +6,7 @@
|
|
|
#include <chrono>
|
|
|
#include "httppeer.h"
|
|
|
#include "techempower.h"
|
|
|
+#include "request.h"
|
|
|
#include "techempower_json.h"
|
|
|
#include "datetime.h"
|
|
|
#include "func.h"
|
|
@@ -43,6 +44,7 @@ asio::awaitable<std::string> techempowerdb(std::shared_ptr<httppeer> peer)
|
|
|
myworld.where("id", rd_num);
|
|
|
myworld.limit(1);
|
|
|
co_await myworld.async_fetch_one();
|
|
|
+
|
|
|
peer->output = myworld.data_tojson();
|
|
|
co_return "";
|
|
|
}
|
|
@@ -64,6 +66,7 @@ asio::awaitable<std::string> techempowerqueries(std::shared_ptr<httppeer> peer)
|
|
|
}
|
|
|
auto myworld = orm::World();
|
|
|
myworld.record.reserve(get_num);
|
|
|
+ myworld.lock_conn();
|
|
|
for (unsigned int i = 0; i < get_num; i++)
|
|
|
{
|
|
|
myworld.wheresql.clear();
|
|
@@ -71,7 +74,7 @@ asio::awaitable<std::string> techempowerqueries(std::shared_ptr<httppeer> peer)
|
|
|
myworld.where("id", rd_num);
|
|
|
co_await myworld.async_fetch_append();
|
|
|
}
|
|
|
-
|
|
|
+ myworld.unlock_conn();
|
|
|
peer->output = myworld.to_json();
|
|
|
co_return "";
|
|
|
}
|
|
@@ -91,7 +94,7 @@ asio::awaitable<std::string> techempowerfortunes(std::shared_ptr<httppeer> peer)
|
|
|
std::sort(myfortune.record.begin(), myfortune.record.end(), [](const auto &lhs, const auto &rhs)
|
|
|
{ return lhs.message < rhs.message; });
|
|
|
peer->val["list"].set_array();
|
|
|
- OBJ_ARRAY item;
|
|
|
+ obj_val item;
|
|
|
for (unsigned int i = 0; i < myfortune.record.size(); i++)
|
|
|
{
|
|
|
item["id"] = myfortune.record[i].id;
|
|
@@ -126,6 +129,7 @@ asio::awaitable<std::string> techempowerupdates(std::shared_ptr<httppeer> peer)
|
|
|
auto myworld = orm::World();
|
|
|
myworld.record.clear();
|
|
|
myworld.record.reserve(get_num);
|
|
|
+ myworld.lock_conn();
|
|
|
for (unsigned int i = 0; i < get_num; i++)
|
|
|
{
|
|
|
myworld.wheresql.clear();
|
|
@@ -139,6 +143,7 @@ asio::awaitable<std::string> techempowerupdates(std::shared_ptr<httppeer> peer)
|
|
|
co_await myworld.async_update("randomnumber");
|
|
|
}
|
|
|
}
|
|
|
+ myworld.unlock_conn();
|
|
|
peer->output = myworld.to_json();
|
|
|
co_return "";
|
|
|
}
|
|
@@ -247,4 +252,4 @@ asio::awaitable<std::string> techempowercached_db(std::shared_ptr<httppeer> peer
|
|
|
co_return "";
|
|
|
}
|
|
|
|
|
|
-}// namespace http
|
|
|
+}// namespace http
|