Skip to content

Commit

Permalink
chore: migration log
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed May 17, 2024
1 parent c164b84 commit b178039
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/__migration__/testActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Collection, Db } from "mongodb";

import readlineSync from "readline-sync";

const batchSize = 50;

let appRunning = true;
let db: Db | undefined;
let userCollection: Collection<MonkeyTypes.DBUser>;
Expand Down Expand Up @@ -61,7 +63,7 @@ export async function migrate(): Promise<void> {
await migrateResults();
}

async function migrateResults(batchSize = 50): Promise<void> {
async function migrateResults(): Promise<void> {
const allUsersCount = await userCollection.countDocuments(filter);
if (allUsersCount === 0) {
console.log("No users to migrate.");
Expand Down Expand Up @@ -246,7 +248,9 @@ function updateProgress(
process.stdout.clearLine?.(0);
process.stdout.cursorTo?.(0);
process.stdout.write(
`Previous batch took ${Math.round(previousBatchSizeTime)}ms ${Math.round(
`Previous batch took ${Math.round(previousBatchSizeTime)}ms (~${
previousBatchSizeTime / batchSize
}ms per user) ${Math.round(
percentage
)}% done, estimated time left ${timeLeft} seconds.`
);
Expand Down

0 comments on commit b178039

Please sign in to comment.