From 70ed47bd0047d93e47bf2909cf4b57b12b84a110 Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Tue, 26 Nov 2024 02:46:05 -0500 Subject: [PATCH] fix: erro handling --- src/adapters/supabase/helpers/comment.ts | 4 +- src/adapters/supabase/helpers/issues.ts | 50 +++--------------------- src/handlers/add-comments.ts | 2 +- 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/src/adapters/supabase/helpers/comment.ts b/src/adapters/supabase/helpers/comment.ts index c130e8e..7e25e70 100644 --- a/src/adapters/supabase/helpers/comment.ts +++ b/src/adapters/supabase/helpers/comment.ts @@ -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, @@ -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, diff --git a/src/adapters/supabase/helpers/issues.ts b/src/adapters/supabase/helpers/issues.ts index bad5912..1619e98 100644 --- a/src/adapters/supabase/helpers/issues.ts +++ b/src/adapters/supabase/helpers/issues.ts @@ -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, @@ -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, @@ -164,49 +164,11 @@ export class Issue extends SuperSupabase { return data; } - async findSimilarIssues(markdown: string, threshold: number, currentId: string): Promise { - 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) { - 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 { - 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); } } diff --git a/src/handlers/add-comments.ts b/src/handlers/add-comments.ts index 2dcd7b8..1e184e4 100644 --- a/src/handlers/add-comments.ts +++ b/src/handlers/add-comments.ts @@ -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 });