Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOP-4010: fix console.time warnings #912

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/persistence/src/services/connector/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export const db = async () => {
};

// all docs should be inserted with the buildId for the run.
export const insert = async (docs: any[], collection: string, buildId: ObjectId) => {
export const insert = async (docs: any[], collection: string, buildId: ObjectId, printTime = false) => {
const timerLabel = `insert - ${collection}`;
console.time(timerLabel);
if (printTime) console.time(timerLabel);
const insertSession = await db();
try {
return insertSession.collection(collection).insertMany(
Expand All @@ -55,7 +55,7 @@ export const insert = async (docs: any[], collection: string, buildId: ObjectId)
console.error(`Error at insertion time for ${collection}: ${error}`);
throw error;
} finally {
console.timeEnd(timerLabel);
if (printTime) console.timeEnd(timerLabel);
}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/persistence/src/services/metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const verifyMetadata = async (metadata: Metadata) => {

export const insertMetadata = async (buildId: ObjectId, metadata: Metadata) => {
try {
return insert([metadata], COLLECTION_NAME, buildId);
return insert([metadata], COLLECTION_NAME, buildId, true);
} catch (error) {
console.error(`Error at insertion time for ${COLLECTION_NAME}: ${error}`);
throw error;
Expand Down
2 changes: 1 addition & 1 deletion modules/persistence/src/services/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const updatePages = async (pages: Page[], collection: string, githubUser: string
export const insertAndUpdatePages = async (buildId: ObjectId, zip: AdmZip, githubUser: string) => {
try {
const pages = pagesFromZip(zip, githubUser);
const ops: PromiseLike<any>[] = [insert(pages, COLLECTION_NAME, buildId)];
const ops: PromiseLike<any>[] = [insert(pages, COLLECTION_NAME, buildId, true)];

const featureEnabled = process.env.FEATURE_FLAG_UPDATE_PAGES;
if (featureEnabled && featureEnabled.toUpperCase() === 'TRUE') {
Expand Down