Add awaiter to /recreatestats
This commit is contained in:
parent
f3ae2e4046
commit
1683b76c65
|
@ -877,16 +877,17 @@ app.post('/getstats', jsonParser, function (request, response) {
|
|||
* @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)) {
|
||||
app.post('/recreatestats', jsonParser, async function (request, response) {
|
||||
try {
|
||||
await statsHelpers.loadStatsFile(DIRECTORIES.chats, DIRECTORIES.characters, true);
|
||||
return response.sendStatus(200);
|
||||
} else {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Handle a POST request to update the stats object
|
||||
*
|
||||
|
|
|
@ -147,7 +147,7 @@ async function collectAndCreateStats(chatsPath, charactersPath) {
|
|||
* @param {string} charactersPath - The path to the directory containing the character files.
|
||||
*/
|
||||
async function loadStatsFile(chatsPath, charactersPath, recreateStats = false) {
|
||||
if(recreateStats) {
|
||||
if (recreateStats) {
|
||||
charStats = await collectAndCreateStats(chatsPath, charactersPath); // Call your function to collect and create stats
|
||||
await saveStatsToFile();
|
||||
console.debug('Stats recreated and saved to file.');
|
||||
|
|
Loading…
Reference in New Issue