Skip to content

Commit

Permalink
Made embeddings add as batched
Browse files Browse the repository at this point in the history
  • Loading branch information
craigloewen-msft committed Nov 18, 2023
1 parent 8364057 commit 5b5615c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions backendsrc/refreshRepoHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class RefreshRepoTask {

async storeInDatabase(data) {
var response = 'success';
var insertedIssueArray = [];

await Promise.all(data.map(async (responseItem) => {
// for (let i = 0; i < data.length; i++) {
Expand Down Expand Up @@ -291,8 +292,8 @@ class RefreshRepoTask {
// Add in await to the promise array for adding embedding title
// Check if an issue was inserted
if (!updateResultRaw.lastErrorObject.updatedExisting) {
// Log to console starting adding embedding for issue
this.embeddingsHandler.addEmbedding(updateResult);
// Add inserted issue to list
insertedIssueArray.push(updateResult);
}

if (updateResult.closed_by) {
Expand All @@ -306,8 +307,6 @@ class RefreshRepoTask {
finalAwaitPromiseArray.push(helperFunctions.UpdateIssueRead(this.IssueReadDetails, updateResult, authorUser, updateResult.created_at));
}



// If closer user exists and issue is closed
if (updateResult.state == "closed") {
let closerUser = null;
Expand Down Expand Up @@ -338,6 +337,12 @@ class RefreshRepoTask {
}
}));

// Log to console how many issues we're adding embeddings for and the repo name
console.log("Adding embeddings for " + insertedIssueArray.length + " issues in " + this.shortRepoUrl);

// Add embeddings for all inserted issues
await this.embeddingsHandler.addMultipleEmbeddings(insertedIssueArray);

return response;
}

Expand Down

0 comments on commit 5b5615c

Please sign in to comment.