Skip to content

Commit

Permalink
added optional arg to insert
Browse files Browse the repository at this point in the history
  • Loading branch information
mayaraman19 committed Sep 21, 2023
1 parent d21b958 commit debb4ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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: boolean = false) => {

Check failure on line 41 in modules/persistence/src/services/connector/index.ts

View workflow job for this annotation

GitHub Actions / test

Type boolean trivially inferred from a boolean literal, remove type annotation
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

0 comments on commit debb4ee

Please sign in to comment.