Skip to content

Commit

Permalink
fix: erro handling
Browse files Browse the repository at this point in the history
  • Loading branch information
sshivaditya committed Nov 26, 2024
1 parent 2ed32fb commit 70ed47b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/adapters/supabase/helpers/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class Comment extends SuperSupabase {
this.context.logger.error("Error updating comment", {
Error: error,
commentData: {
id: commentData.id,
commentData,
markdown: finalMarkdown,
plaintext,
embedding,
Expand All @@ -105,7 +105,7 @@ export class Comment extends SuperSupabase {
}
this.context.logger.info("Comment updated successfully with id: " + commentData.id, {
commentData: {
id: commentData.id,
commentData,
markdown: finalMarkdown,
plaintext,
embedding,
Expand Down
50 changes: 6 additions & 44 deletions src/adapters/supabase/helpers/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class Issue extends SuperSupabase {
this.context.logger.error("Error updating issue", {
Error: error,
issueData: {
id: issueData.id,
...issueData,
markdown: finalMarkdown,
plaintext,
embedding,
Expand All @@ -139,7 +139,7 @@ export class Issue extends SuperSupabase {
}
this.context.logger.info("Issue updated successfully with id: " + issueData.id, {
issueData: {
id: issueData.id,
...issueData,
markdown: finalMarkdown,
plaintext,
embedding,
Expand All @@ -164,49 +164,11 @@ export class Issue extends SuperSupabase {
return data;
}

async findSimilarIssues(markdown: string, threshold: number, currentId: string): Promise<IssueSimilaritySearchResult[]> {
try {
const embedding = await this.context.adapters.voyage.embedding.createEmbedding(markdown, "query");
const { data, error } = await this.supabase.rpc("find_similar_issues", {
current_id: currentId,
query_embedding: embedding,
threshold,
top_k: 5,
});
if (error) {
this.context.logger.error("Error finding similar issues", {
Error: error,
markdown,
threshold,
currentId,
});
return [];
}
return data;
} catch (error) {
this.context.logger.error("Error finding similar issues", {
Error: error,
markdown,
threshold,
currentId,
});
return [];
}
}

async updatePayload(issueNodeId: string, payload: Record<string, unknown>) {
const { error } = await this.supabase.from("issues").update({ payload }).eq("id", issueNodeId);
if (error) {
this.context.logger.error("Error updating issue payload", { err: error });
}
}

async isIssuePresent(issueNodeId: string): Promise<boolean> {
const { data, error } = await this.supabase.from("issues").select("*").eq("id", issueNodeId);
async deleteIssue(issueNodeId: string) {
const { error } = await this.supabase.from("issues").delete().eq("id", issueNodeId);
if (error) {
this.context.logger.error("Error checking if issue is present", error);
return false;
this.context.logger.error("Error deleting issue", { err: error });
}
return data && data.length > 0;
this.context.logger.info("Issue deleted successfully with id: " + issueNodeId);
}
}
2 changes: 1 addition & 1 deletion src/handlers/add-comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function addComments(context: Context<"issue_comment.created">) {
logger.error("Comment is on a pull request");
}
if ((await supabase.issue.getIssue(issueId)) === null) {
logger.info("Parent issue not found, creating new issue");
logger.info("Parent issue not found, creating new issue", { "Issue ID": issueId });
await addIssue(context as unknown as Context<"issues.opened">);
}
await supabase.comment.createComment({ markdown, id, author_id: authorId, payload, isPrivate, issue_id: issueId });
Expand Down

0 comments on commit 70ed47b

Please sign in to comment.