diff --git a/libs/database/sqlite2mongo/postTasks.js b/libs/database/sqlite2mongo/postTasks.js index 0162fdf..8d7b242 100644 --- a/libs/database/sqlite2mongo/postTasks.js +++ b/libs/database/sqlite2mongo/postTasks.js @@ -38,6 +38,7 @@ export default async function postTasks() { log("Done!") log("Processing points for players...") + const totalPlayers = await Player.find({}).count() let processedPlayerPoints = 0 for (const entry of cache.pointsRanks) { spread( @@ -49,7 +50,7 @@ export default async function postTasks() { ).then( () => { ++processedPlayerPoints - log(`Processed player ${processedPlayerPoints}/${cache.pointsRanks.length} -> «${entry[0]}» has ${entry[1]} points!`) + log(`Processed player ${processedPlayerPoints}/${totalPlayers} -> «${entry[0]}» has ${entry[1]} points!`) } ) } @@ -61,7 +62,7 @@ export default async function postTasks() { './playerRankPoints.js', { name: entry[0], - rankPoints: [1] + rankPoints: entry[1] } ).then( () => { diff --git a/libs/utils/multithread.js b/libs/utils/multithread.js index e1a4d5b..82b7345 100644 --- a/libs/utils/multithread.js +++ b/libs/utils/multithread.js @@ -60,7 +60,7 @@ export function initWorkers(threads) { setInterval( scheduler, - 50 + process.env.SCHEDULE_TIME ?? 50 ) log(`Initialised the scheduler!`) diff --git a/schemas/Player.js b/schemas/Player.js index 6658f51..a75ce67 100644 --- a/schemas/Player.js +++ b/schemas/Player.js @@ -10,6 +10,8 @@ const Player = new mongoose.Schema({ firstFinish: Date }) +Player.index({ name: 1 }) + /** * This cotains the mongoose 'Player' model. * @module schemas/Player