Ändere die Überprüfung auf die Erstellung von Charakteren von "vorheriger Tag" zu "heutiger Tag"
This commit is contained in:
committed by
Torsten (PC)
parent
1fe77c0905
commit
51fd9fcd13
@@ -17,7 +17,7 @@ CharacterCreationWorker::~CharacterCreationWorker() {
|
||||
void CharacterCreationWorker::run() {
|
||||
while (runningWorker) {
|
||||
setCurrentStep("Check if previous day character was created");
|
||||
if (!isPreviousDayCharacterCreated()) {
|
||||
if (!isTodayCharacterCreated()) {
|
||||
setCurrentStep("Create characters for today");
|
||||
createCharactersForToday();
|
||||
}
|
||||
@@ -31,21 +31,19 @@ void CharacterCreationWorker::run() {
|
||||
}
|
||||
}
|
||||
|
||||
bool CharacterCreationWorker::isPreviousDayCharacterCreated() {
|
||||
bool CharacterCreationWorker::isTodayCharacterCreated() {
|
||||
try {
|
||||
setCurrentStep("Get Database Connection");
|
||||
ConnectionGuard connGuard(pool);
|
||||
auto &db = connGuard.get();
|
||||
|
||||
setCurrentStep("Execute Query");
|
||||
auto results = db.query(QUERY_IS_PREVIOUS_DAY_CHARACTER_CREATED);
|
||||
|
||||
if (!results.empty()) {
|
||||
std::string created_at_str = results[0].at("created_at");
|
||||
return true;
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "[CharacterCreationWorker] Fehler in isPreviousDayCharacterCreated: "
|
||||
std::cerr << "[CharacterCreationWorker] Fehler in isTodayCharacterCreated: "
|
||||
<< e.what() << std::endl;
|
||||
}
|
||||
setCurrentStep("No previous day character found");
|
||||
@@ -97,10 +95,10 @@ void CharacterCreationWorker::createCharacter(int region_id,
|
||||
|
||||
db.prepare("insert_character", QUERY_INSERT_CHARACTER);
|
||||
db.execute("insert_character", {std::to_string(region_id),
|
||||
std::to_string(first_name_id),
|
||||
std::to_string(last_name_id),
|
||||
gender,
|
||||
std::to_string(title_of_nobility)});
|
||||
std::to_string(first_name_id),
|
||||
std::to_string(last_name_id),
|
||||
gender,
|
||||
std::to_string(title_of_nobility)});
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "[CharacterCreationWorker] Fehler in createCharacter: "
|
||||
<< e.what() << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user