Ä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() {
|
void CharacterCreationWorker::run() {
|
||||||
while (runningWorker) {
|
while (runningWorker) {
|
||||||
setCurrentStep("Check if previous day character was created");
|
setCurrentStep("Check if previous day character was created");
|
||||||
if (!isPreviousDayCharacterCreated()) {
|
if (!isTodayCharacterCreated()) {
|
||||||
setCurrentStep("Create characters for today");
|
setCurrentStep("Create characters for today");
|
||||||
createCharactersForToday();
|
createCharactersForToday();
|
||||||
}
|
}
|
||||||
@@ -31,21 +31,19 @@ void CharacterCreationWorker::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CharacterCreationWorker::isPreviousDayCharacterCreated() {
|
bool CharacterCreationWorker::isTodayCharacterCreated() {
|
||||||
try {
|
try {
|
||||||
setCurrentStep("Get Database Connection");
|
setCurrentStep("Get Database Connection");
|
||||||
ConnectionGuard connGuard(pool);
|
ConnectionGuard connGuard(pool);
|
||||||
auto &db = connGuard.get();
|
auto &db = connGuard.get();
|
||||||
|
|
||||||
setCurrentStep("Execute Query");
|
setCurrentStep("Execute Query");
|
||||||
auto results = db.query(QUERY_IS_PREVIOUS_DAY_CHARACTER_CREATED);
|
auto results = db.query(QUERY_IS_PREVIOUS_DAY_CHARACTER_CREATED);
|
||||||
|
|
||||||
if (!results.empty()) {
|
if (!results.empty()) {
|
||||||
std::string created_at_str = results[0].at("created_at");
|
std::string created_at_str = results[0].at("created_at");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
std::cerr << "[CharacterCreationWorker] Fehler in isPreviousDayCharacterCreated: "
|
std::cerr << "[CharacterCreationWorker] Fehler in isTodayCharacterCreated: "
|
||||||
<< e.what() << std::endl;
|
<< e.what() << std::endl;
|
||||||
}
|
}
|
||||||
setCurrentStep("No previous day character found");
|
setCurrentStep("No previous day character found");
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ private:
|
|||||||
std::unordered_map<std::string, std::unordered_set<int>> first_name_cache;
|
std::unordered_map<std::string, std::unordered_set<int>> first_name_cache;
|
||||||
std::unordered_set<int> last_name_cache;
|
std::unordered_set<int> last_name_cache;
|
||||||
|
|
||||||
bool isPreviousDayCharacterCreated();
|
bool isTodayCharacterCreated();
|
||||||
void createCharactersForToday();
|
void createCharactersForToday();
|
||||||
void createCharactersForRegion(int region_id);
|
void createCharactersForRegion(int region_id);
|
||||||
void createCharacter(int region_id, const std::string &gender, int title_of_nobility);
|
void createCharacter(int region_id, const std::string &gender, int title_of_nobility);
|
||||||
@@ -33,6 +33,7 @@ private:
|
|||||||
SELECT created_at
|
SELECT created_at
|
||||||
FROM falukant_data."character"
|
FROM falukant_data."character"
|
||||||
WHERE user_id IS NULL
|
WHERE user_id IS NULL
|
||||||
|
AND created_at::date = CURRENT_DATE
|
||||||
ORDER BY created_at DESC
|
ORDER BY created_at DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
)";
|
)";
|
||||||
@@ -59,6 +60,6 @@ private:
|
|||||||
user_id, region_id, first_name, last_name,
|
user_id, region_id, first_name, last_name,
|
||||||
birthdate, gender, created_at, updated_at, title_of_nobility
|
birthdate, gender, created_at, updated_at, title_of_nobility
|
||||||
)
|
)
|
||||||
VALUES ($1, $2, $3, $4, NOW(), $5, NOW(), NOW(), $6);
|
VALUES (NULL, $1, $2, $3, NOW(), $4, NOW(), NOW(), $5);
|
||||||
)";
|
)";
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user