Quick and dirty stat re-creator button

This commit is contained in:
city-unit
2023-09-21 17:34:09 -04:00
parent ae4a9a7b14
commit cd1a8c9224
3 changed files with 71 additions and 5 deletions

View File

@@ -1297,6 +1297,26 @@ app.post("/getstats", jsonParser, function (request, response) {
response.send(JSON.stringify(statsHelpers.getCharStats()));
});
/**
* Endpoint: POST /recreatestats
*
* Triggers the recreation of statistics from chat files.
* - If successful: returns a 200 OK status.
* - On failure: returns a 500 Internal Server Error status.
*
* @param {Object} request - Express request object.
* @param {Object} response - Express response object.
*/
app.post("/recreatestats", jsonParser, function (request, response) {
if (statsHelpers.loadStatsFile(DIRECTORIES.chats, DIRECTORIES.characters, true)) {
return response.sendStatus(200);
} else {
return response.sendStatus(500);
}
});
/**
* Handle a POST request to update the stats object
*