mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
Use fmt join for simple query strings
This commit is contained in:
parent
b46eca4ec6
commit
074b7096df
@ -143,29 +143,17 @@ void ExpeditionDatabase::DeleteExpeditions(const std::vector<uint32_t>& expediti
|
|||||||
{
|
{
|
||||||
LogExpeditionsDetail("Deleting [{}] expedition(s)", expedition_ids.size());
|
LogExpeditionsDetail("Deleting [{}] expedition(s)", expedition_ids.size());
|
||||||
|
|
||||||
std::string expedition_ids_query;
|
std::string expedition_ids_query = fmt::format("{}", fmt::join(expedition_ids, ","));
|
||||||
for (const auto& expedition_id : expedition_ids)
|
|
||||||
{
|
|
||||||
fmt::format_to(std::back_inserter(expedition_ids_query), "{},", expedition_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!expedition_ids_query.empty())
|
if (!expedition_ids_query.empty())
|
||||||
{
|
{
|
||||||
expedition_ids_query.pop_back(); // trailing comma
|
auto query = fmt::format("DELETE FROM expeditions WHERE id IN ({});", expedition_ids_query);
|
||||||
|
|
||||||
std::string query = fmt::format(
|
|
||||||
"DELETE FROM expeditions WHERE id IN ({});", expedition_ids_query
|
|
||||||
);
|
|
||||||
database.QueryDatabase(query);
|
database.QueryDatabase(query);
|
||||||
|
|
||||||
query = fmt::format(
|
query = fmt::format("DELETE FROM expedition_members WHERE expedition_id IN ({});", expedition_ids_query);
|
||||||
"DELETE FROM expedition_members WHERE expedition_id IN ({});", expedition_ids_query
|
|
||||||
);
|
|
||||||
database.QueryDatabase(query);
|
database.QueryDatabase(query);
|
||||||
|
|
||||||
query = fmt::format(
|
query = fmt::format("DELETE FROM expedition_lockouts WHERE expedition_id IN ({});", expedition_ids_query);
|
||||||
"DELETE FROM expedition_lockouts WHERE expedition_id IN ({});", expedition_ids_query
|
|
||||||
);
|
|
||||||
database.QueryDatabase(query);
|
database.QueryDatabase(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,18 +56,12 @@ std::unordered_map<uint32_t, DynamicZone> DynamicZone::LoadMultipleDzFromDatabas
|
|||||||
{
|
{
|
||||||
LogDynamicZonesDetail("Loading dynamic zone data for [{}] instances", dynamic_zone_ids.size());
|
LogDynamicZonesDetail("Loading dynamic zone data for [{}] instances", dynamic_zone_ids.size());
|
||||||
|
|
||||||
std::string in_dynamic_zone_ids_query;
|
std::string in_dynamic_zone_ids_query = fmt::format("{}", fmt::join(dynamic_zone_ids, ","));
|
||||||
for (const auto& dynamic_zone_id : dynamic_zone_ids)
|
|
||||||
{
|
|
||||||
fmt::format_to(std::back_inserter(in_dynamic_zone_ids_query), "{},", dynamic_zone_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_map<uint32_t, DynamicZone> dynamic_zones;
|
std::unordered_map<uint32_t, DynamicZone> dynamic_zones;
|
||||||
|
|
||||||
if (!in_dynamic_zone_ids_query.empty())
|
if (!in_dynamic_zone_ids_query.empty())
|
||||||
{
|
{
|
||||||
in_dynamic_zone_ids_query.pop_back(); // trailing comma
|
|
||||||
|
|
||||||
std::string query = fmt::format(SQL(
|
std::string query = fmt::format(SQL(
|
||||||
{} WHERE dynamic_zones.id IN ({});
|
{} WHERE dynamic_zones.id IN ({});
|
||||||
), DynamicZoneSelectQuery(), in_dynamic_zone_ids_query);
|
), DynamicZoneSelectQuery(), in_dynamic_zone_ids_query);
|
||||||
|
|||||||
@ -176,19 +176,13 @@ ExpeditionDatabase::LoadMultipleExpeditionLockouts(
|
|||||||
{
|
{
|
||||||
LogExpeditionsDetail("Loading internal lockouts for [{}] expeditions", expedition_ids.size());
|
LogExpeditionsDetail("Loading internal lockouts for [{}] expeditions", expedition_ids.size());
|
||||||
|
|
||||||
std::string in_expedition_ids_query;
|
std::string in_expedition_ids_query = fmt::format("{}", fmt::join(expedition_ids, ","));
|
||||||
for (const auto& expedition_id : expedition_ids)
|
|
||||||
{
|
|
||||||
fmt::format_to(std::back_inserter(in_expedition_ids_query), "{},", expedition_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// these are loaded into the same container type expeditions use to store lockouts
|
// these are loaded into the same container type expeditions use to store lockouts
|
||||||
std::unordered_map<uint32_t, std::unordered_map<std::string, ExpeditionLockoutTimer>> lockouts;
|
std::unordered_map<uint32_t, std::unordered_map<std::string, ExpeditionLockoutTimer>> lockouts;
|
||||||
|
|
||||||
if (!in_expedition_ids_query.empty())
|
if (!in_expedition_ids_query.empty())
|
||||||
{
|
{
|
||||||
in_expedition_ids_query.pop_back(); // trailing comma
|
|
||||||
|
|
||||||
std::string query = fmt::format(SQL(
|
std::string query = fmt::format(SQL(
|
||||||
SELECT
|
SELECT
|
||||||
expedition_lockouts.expedition_id,
|
expedition_lockouts.expedition_id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user