mirror of
https://github.com/SamyRai/tercul-frontend.git
synced 2025-12-27 02:31:34 +00:00
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
This commit is contained in:
parent
14a42223a8
commit
085270ea6f
@ -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<AnalysisResult[]> {
|
||||
return Array.from(this.analysisResults.values()).filter(
|
||||
result => result.workId === workId
|
||||
);
|
||||
}
|
||||
|
||||
async getAnalysisResultById(id: number): Promise<AnalysisResult | undefined> {
|
||||
return this.analysisResults.get(id);
|
||||
}
|
||||
|
||||
async getAnalysisResultByWorkAndType(workId: number, type: string): Promise<AnalysisResult | undefined> {
|
||||
return Array.from(this.analysisResults.values()).find(
|
||||
result => result.workId === workId && result.type === type
|
||||
);
|
||||
}
|
||||
|
||||
async createAnalysisResult(insertResult: InsertAnalysisResult): Promise<AnalysisResult> {
|
||||
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<Annotation[]> {
|
||||
return Array.from(this.annotations.values()).filter(
|
||||
annotation => annotation.workId === workId
|
||||
);
|
||||
}
|
||||
|
||||
async getAnnotationsByTranslationId(translationId: number): Promise<Annotation[]> {
|
||||
return Array.from(this.annotations.values()).filter(
|
||||
annotation => annotation.translationId === translationId
|
||||
);
|
||||
}
|
||||
|
||||
async getAnnotationsByLine(workId: number, lineNumber: number, translationId?: number): Promise<Annotation[]> {
|
||||
return Array.from(this.annotations.values()).filter(
|
||||
annotation => annotation.workId === workId &&
|
||||
annotation.lineNumber === lineNumber &&
|
||||
(translationId === undefined || annotation.translationId === translationId)
|
||||
);
|
||||
}
|
||||
|
||||
async getAnnotationById(id: number): Promise<Annotation | undefined> {
|
||||
return this.annotations.get(id);
|
||||
}
|
||||
|
||||
async createAnnotation(insertAnnotation: InsertAnnotation): Promise<Annotation> {
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user