-
Notifications
You must be signed in to change notification settings - Fork 0
Fix correction import schema and update dependencies #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9d67706
5d9344f
3ca2945
6aff059
179a5f1
f604d31
1202c10
45cfb60
0cc268c
7de9ea5
9f20c02
c055dee
e949a14
f0e8b18
a20c1d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,10 @@ export interface ImportKbrCorrectionBundleInput { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finalizeCorrection?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface ImportKbrCorrectionBundleBatchInput extends Omit<ImportKbrCorrectionBundleInput, 'bundle'> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bundles: unknown[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface ImportKbrCorrectionBundleResult { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| correction: Exams.CorrectionEntry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| candidateId: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -53,6 +57,14 @@ export interface ImportKbrCorrectionBundleResult { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uncertainties: CorrectionImportUncertainty[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface ImportKbrCorrectionBundleBatchResult { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| results: ImportKbrCorrectionBundleResult[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| importedBundleCount: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| importedTaskScoreCount: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skippedTaskScoreCount: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uncertainties: CorrectionImportUncertainty[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function asRecord(value: unknown): Record<string, unknown> | undefined { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof value !== 'object' || value === null || Array.isArray(value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return undefined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -209,6 +221,22 @@ export class ImportKbrCorrectionBundleUseCase { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly recordCorrectionUseCase: RecordCorrectionUseCase | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async executeMany(input: ImportKbrCorrectionBundleBatchInput): Promise<ImportKbrCorrectionBundleBatchResult> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const results: ImportKbrCorrectionBundleResult[] = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const bundle of input.bundles) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| results.push(await this.execute({ ...input, bundle })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| results, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| importedBundleCount: results.length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| importedTaskScoreCount: results.reduce((sum, result) => sum + result.importedTaskScoreCount, 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| skippedTaskScoreCount: results.reduce((sum, result) => sum + result.skippedTaskScoreCount, 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uncertainties: results.flatMap((result) => result.uncertainties) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+224
to
+238
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spreading Additionally, since this method processes multiple bundles sequentially using
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async execute(input: ImportKbrCorrectionBundleInput): Promise<ImportKbrCorrectionBundleResult> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const schema = input.schema ?? getDefaultCorrectionImportBundleSchema(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { bundle } = validateCorrectionImportBundle(input.bundle, schema); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
input.bundleis an array, spreadinginputdirectly intoexecuteManymeans the duplicatebundleproperty (which is the array) is still passed along with the newbundlesproperty. Destructuringbundleout ofinputfirst keeps the payload clean and avoids passing redundant properties.