Skip to content

Commit

Permalink
fix: remove db
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Nov 24, 2024
1 parent 245dec7 commit 02bc3dd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/creatures/players/components/player_forge_history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ bool PlayerForgeHistory::save() {

auto playerGUID = m_player.getGUID();

Database &db = Database::getInstance();

if (!m_removedHistoryIds.empty()) {
std::string idsToDelete = fmt::format("{}", fmt::join(m_removedHistoryIds, ", "));
std::string deleteQuery = fmt::format(
"DELETE FROM `forge_history` WHERE `player_id` = {} AND `id` IN ({})",
playerGUID, idsToDelete
);

if (!db.executeQuery(deleteQuery)) {
if (!g_database().executeQuery(deleteQuery)) {
g_logger().error("Failed to delete forge history entries for player with ID: {}", playerGUID);
return false;
}
Expand All @@ -84,7 +82,7 @@ bool PlayerForgeHistory::save() {
insertQuery.upsert({ "action_type", "description", "done_at", "is_success" });

for (const auto &history : m_modifiedHistory) {
auto row = fmt::format("{}, {}, {}, {}, {}, {}", history.id, playerGUID, history.actionType, db.escapeString(history.description), history.createdAt, history.success ? 1 : 0);
auto row = fmt::format("{}, {}, {}, {}, {}, {}", history.id, playerGUID, history.actionType, g_database().escapeString(history.description), history.createdAt, history.success ? 1 : 0);

if (!insertQuery.addRow(row)) {
g_logger().warn("Failed to add forge history entry for player with ID: {}", playerGUID);
Expand Down

0 comments on commit 02bc3dd

Please sign in to comment.