From 085270ea6f838e3eaa5261e47da2fc94ae97e596 Mon Sep 17 00:00:00 2001 From: mukimovd <41473651-mukimovd@users.noreply.replit.com> Date: Thu, 8 May 2025 00:18:18 +0000 Subject: [PATCH] Add methods to retrieve and store analysis results and annotations Implement new methods in storage.ts to manage analysis results and annotations. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cbacfb18-842a-4116-a907-18c0105ad8ec Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/39b5c689-6e8a-4d5a-9792-69cc81a56534/88f93614-9963-4c58-9597-c6404ee3b576.jpg --- server/storage.ts | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/server/storage.ts b/server/storage.ts index 817ad26..ef37b85 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -1205,6 +1205,72 @@ As we continue to develop the Tercul platform, we're committed to addressing the return filtered; } + + // Analysis methods + async getAnalysisResultsByWorkId(workId: number): Promise { + return Array.from(this.analysisResults.values()).filter( + result => result.workId === workId + ); + } + + async getAnalysisResultById(id: number): Promise { + return this.analysisResults.get(id); + } + + async getAnalysisResultByWorkAndType(workId: number, type: string): Promise { + return Array.from(this.analysisResults.values()).find( + result => result.workId === workId && result.type === type + ); + } + + async createAnalysisResult(insertResult: InsertAnalysisResult): Promise { + const id = this.analysisResultId++; + const now = new Date(); + const result: AnalysisResult = { + ...insertResult, + id, + createdAt: now + }; + this.analysisResults.set(id, result); + return result; + } + + // Annotation methods + async getAnnotationsByWorkId(workId: number): Promise { + return Array.from(this.annotations.values()).filter( + annotation => annotation.workId === workId + ); + } + + async getAnnotationsByTranslationId(translationId: number): Promise { + return Array.from(this.annotations.values()).filter( + annotation => annotation.translationId === translationId + ); + } + + async getAnnotationsByLine(workId: number, lineNumber: number, translationId?: number): Promise { + return Array.from(this.annotations.values()).filter( + annotation => annotation.workId === workId && + annotation.lineNumber === lineNumber && + (translationId === undefined || annotation.translationId === translationId) + ); + } + + async getAnnotationById(id: number): Promise { + return this.annotations.get(id); + } + + async createAnnotation(insertAnnotation: InsertAnnotation): Promise { + const id = this.annotationId++; + const now = new Date(); + const annotation: Annotation = { + ...insertAnnotation, + id, + createdAt: now + }; + this.annotations.set(id, annotation); + return annotation; + } } // Now using JsonStorage instead of MemStorage