Clear stale pending expedition lockouts

Delete pending lockouts of members on expedition creation

Delete pending lockouts when all members removed from expedition

This fixes an edge case where members could incorrectly be assigned
pending lockouts that were never cleared from the database (from a
server crash or other situation) after entering another dz.
This commit is contained in:
hg
2020-06-13 21:28:21 -04:00
parent 3f3cb9114b
commit 7e532869a0
5 changed files with 32 additions and 2 deletions
+23
View File
@@ -379,6 +379,29 @@ void ExpeditionDatabase::DeletePendingLockouts(uint32_t character_id)
database.QueryDatabase(query);
}
void ExpeditionDatabase::DeleteAllMembersPendingLockouts(const std::vector<ExpeditionMember>& members)
{
LogExpeditionsDetail("Deleting pending lockouts for [{}] characters", members.size());
std::string query_character_ids;
for (const auto& member : members)
{
fmt::format_to(std::back_inserter(query_character_ids), "{},", member.char_id);
}
if (!query_character_ids.empty())
{
query_character_ids.pop_back(); // trailing comma
auto query = fmt::format(SQL(
DELETE FROM expedition_character_lockouts
WHERE character_id IN ({}) AND is_pending = TRUE;
), query_character_ids);
database.QueryDatabase(query);
}
}
void ExpeditionDatabase::DeleteLockout(uint32_t expedition_id, const std::string& event_name)
{
LogExpeditionsDetail("Deleting expedition [{}] lockout event [{}]", expedition_id, event_name);