MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / updateCodeReviewStatus

Function updateCodeReviewStatus

apps/web/src/lib/code-reviews/db/code-reviews.ts:886–966  ·  view source on GitHub ↗
(
  reviewId: string,
  status: CodeReviewStatus,
  updates: {
    sessionId?: string;
    cliSessionId?: string;
    errorMessage?: string;
    terminalReason?: CodeReviewTerminalReason;
    startedAt?: Date;
    completedAt?: Date;
    agentVersion?: string;
    model?: string;
    totalTokensIn?: number;
    totalTokensOut?: number;
    totalCostMusd?: number;
  } = {}
)

Source from the content-addressed store, hash-verified

884 .set(
885 buildAttemptUpdateData({
886 status: params.status,
887 sessionId: params.sessionId,
888 cliSessionId: params.cliSessionId,
889 executionId: params.executionId,
890 errorMessage: params.errorMessage,
891 terminalReason: params.terminalReason,
892 startedAt: params.startedAt,
893 completedAt: params.completedAt,
894 })
895 )
896 .where(eq(cloud_agent_code_review_attempts.id, targetAttempt.id))
897 .returning();
898
899 if (!updated) {
900 throw new Error('Failed to update code review attempt');
901 }
902
903 return updated;
904 } catch (error) {
905 captureException(error, {
906 tags: { operation: 'updateCodeReviewAttemptForCallback' },
907 extra: { params },
908 });
909 throw error;
910 }
911}
912
913export async function hasInfraRetryAttempt(codeReviewId: string): Promise<boolean> {
914 try {
915 const [attempt] = await db
916 .select({ id: cloud_agent_code_review_attempts.id })
917 .from(cloud_agent_code_review_attempts)
918 .where(
919 and(
920 eq(cloud_agent_code_review_attempts.code_review_id, codeReviewId),
921 eq(cloud_agent_code_review_attempts.retry_reason, 'infra_failure')
922 )
923 )
924 .limit(1);
925
926 return !!attempt;
927 } catch (error) {
928 captureException(error, {
929 tags: { operation: 'hasInfraRetryAttempt' },
930 extra: { codeReviewId },
931 });
932 throw error;
933 }
934}
935
936export async function ensureCurrentCodeReviewAttemptFromReview(
937 review: CloudAgentCodeReview,
938 analyticsEnabledAtDispatch?: boolean
939): Promise<CloudAgentCodeReviewAttempt> {
940 let attempt = await getLatestCodeReviewAttempt(review.id);
941 if (attempt) {
942 if (
943 attempt.status === 'pending' &&

Callers 9

createRunningReviewFunction · 0.90
db.test.tsFile · 0.90
createCompletedReviewFunction · 0.90
POSTFunction · 0.90
captureReviewFunction · 0.90
cancelCodeReviewFunction · 0.85

Calls 2

setMethod · 0.65
updateMethod · 0.65

Tested by 4

createRunningReviewFunction · 0.72
createCompletedReviewFunction · 0.72
captureReviewFunction · 0.72