mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +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());
|
||||
|
||||
std::string expedition_ids_query;
|
||||
for (const auto& expedition_id : expedition_ids)
|
||||
{
|
||||
fmt::format_to(std::back_inserter(expedition_ids_query), "{},", expedition_id);
|
||||
}
|
||||
std::string expedition_ids_query = fmt::format("{}", fmt::join(expedition_ids, ","));
|
||||
|
||||
if (!expedition_ids_query.empty())
|
||||
{
|
||||
expedition_ids_query.pop_back(); // trailing comma
|
||||
|
||||
std::string query = fmt::format(
|
||||
"DELETE FROM expeditions WHERE id IN ({});", expedition_ids_query
|
||||
);
|
||||
auto query = fmt::format("DELETE FROM expeditions WHERE id IN ({});", expedition_ids_query);
|
||||
database.QueryDatabase(query);
|
||||
|
||||
query = fmt::format(
|
||||
"DELETE FROM expedition_members WHERE expedition_id IN ({});", expedition_ids_query
|
||||
);
|
||||
query = fmt::format("DELETE FROM expedition_members WHERE expedition_id IN ({});", expedition_ids_query);
|
||||
database.QueryDatabase(query);
|
||||
|
||||
query = fmt::format(
|
||||
"DELETE FROM expedition_lockouts WHERE expedition_id IN ({});", expedition_ids_query
|
||||
);
|
||||
query = fmt::format("DELETE FROM expedition_lockouts WHERE expedition_id IN ({});", expedition_ids_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());
|
||||
|
||||
std::string in_dynamic_zone_ids_query;
|
||||
for (const auto& dynamic_zone_id : dynamic_zone_ids)
|
||||
{
|
||||
fmt::format_to(std::back_inserter(in_dynamic_zone_ids_query), "{},", dynamic_zone_id);
|
||||
}
|
||||
std::string in_dynamic_zone_ids_query = fmt::format("{}", fmt::join(dynamic_zone_ids, ","));
|
||||
|
||||
std::unordered_map<uint32_t, DynamicZone> dynamic_zones;
|
||||
|
||||
if (!in_dynamic_zone_ids_query.empty())
|
||||
{
|
||||
in_dynamic_zone_ids_query.pop_back(); // trailing comma
|
||||
|
||||
std::string query = fmt::format(SQL(
|
||||
{} WHERE dynamic_zones.id IN ({});
|
||||
), DynamicZoneSelectQuery(), in_dynamic_zone_ids_query);
|
||||
|
||||
@ -176,19 +176,13 @@ ExpeditionDatabase::LoadMultipleExpeditionLockouts(
|
||||
{
|
||||
LogExpeditionsDetail("Loading internal lockouts for [{}] expeditions", expedition_ids.size());
|
||||
|
||||
std::string in_expedition_ids_query;
|
||||
for (const auto& expedition_id : expedition_ids)
|
||||
{
|
||||
fmt::format_to(std::back_inserter(in_expedition_ids_query), "{},", expedition_id);
|
||||
}
|
||||
std::string in_expedition_ids_query = fmt::format("{}", fmt::join(expedition_ids, ","));
|
||||
|
||||
// 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;
|
||||
|
||||
if (!in_expedition_ids_query.empty())
|
||||
{
|
||||
in_expedition_ids_query.pop_back(); // trailing comma
|
||||
|
||||
std::string query = fmt::format(SQL(
|
||||
SELECT
|
||||
expedition_lockouts.expedition_id,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user