Repository navigation
Fix Garmin dump import fan-out #1599
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e83a834
Fix Garmin dump import fan-out
Asherlc f67820b
Fix Garmin dump flow edge cases
Asherlc 5bae692
Cover ZIP extraction failure cleanup
Asherlc 3a9f4cd
Merge remote-tracking branch 'origin/main' into Asherlc/garmin-dump-s…
Asherlc bcb2c27
Handle FIT import failures per file
Asherlc 8bfdb0b
Fix Garmin dump Stryker dry run
Asherlc 06cc3f5
Address Garmin dump review feedback
Asherlc b5c2769
Strengthen ZIP queue mutation coverage
Asherlc 27c9959
Cover ZIP open failure branches
Asherlc f4fb68d
Fix ZIP open mock typing
Asherlc 6f210fa
Satisfy ZIP mock lint rules
Asherlc 2ef9482
Address FIT cleanup review comments
Asherlc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { processFitFileImportBatchJob } from "./process-fit-file-import-batch-job.ts"; | ||
|
|
||
| describe("processFitFileImportBatchJob", () => { | ||
| it("aggregates records and errors from child FIT import jobs", async () => { | ||
|
Asherlc marked this conversation as resolved.
Resolved
|
||
| const result = await processFitFileImportBatchJob({ | ||
| getChildrenValues: async () => ({ | ||
| "bull:fit-file-import:1": { recordsSynced: 2, errors: [] }, | ||
| "bull:fit-file-import:2": { | ||
| recordsSynced: 1, | ||
| errors: [{ message: "bad fit" }], | ||
| }, | ||
| }), | ||
| }); | ||
|
|
||
| expect(result).toEqual({ | ||
| recordsSynced: 3, | ||
| errors: [{ message: "bad fit" }], | ||
| }); | ||
| }); | ||
|
|
||
| it("returns an empty result when the batch has no child values", async () => { | ||
| const result = await processFitFileImportBatchJob({ | ||
| getChildrenValues: async () => ({}), | ||
| }); | ||
|
|
||
| expect(result).toEqual({ recordsSynced: 0, errors: [] }); | ||
| }); | ||
|
|
||
| it("rejects malformed child results", async () => { | ||
| await expect( | ||
| processFitFileImportBatchJob({ | ||
| getChildrenValues: async () => ({ | ||
| "bull:fit-file-import:1": { recordsSynced: "2", errors: [] }, | ||
| }), | ||
| }), | ||
| ).rejects.toThrow(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { z } from "zod"; | ||
| import type { FitFileImportJobResult } from "./process-fit-file-import-job.ts"; | ||
|
|
||
| interface FitFileImportBatchJob { | ||
| getChildrenValues: () => Promise<Record<string, unknown>>; | ||
| } | ||
|
|
||
| const fitFileImportJobResultSchema = z.object({ | ||
| recordsSynced: z.number(), | ||
| errors: z.array(z.object({ message: z.string() })), | ||
| }); | ||
|
|
||
| export async function processFitFileImportBatchJob( | ||
| job: FitFileImportBatchJob, | ||
| ): Promise<FitFileImportJobResult> { | ||
| const childValues = await job.getChildrenValues(); | ||
| const results = Object.values(childValues).map((value) => | ||
| fitFileImportJobResultSchema.parse(value), | ||
| ); | ||
|
|
||
| return { | ||
| recordsSynced: results.reduce((total, result) => total + result.recordsSynced, 0), | ||
| errors: results.flatMap((result) => result.errors), | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.