Repository navigation
Conversation
…te default parseInt(duration) || 30 treated 0 as falsy, so a 0-minute session in an imported backup became 30 minutes, inflating study hours, the productivity score and the Century Club achievement. Only fall back to the 30-minute default when the value is not a number; zero and negative values clamp to the 1-minute minimum like any other out-of-range input.
…port date filter Upstream 344b1fc made importJSON drop activities whose date is not a valid ISO date, so the four dateless activities in this fixture were all filtered out on the merge commit and CI saw [] instead of [1, 30, 1, 30]. The duration expectations are unchanged.
Contributor
Author
|
The earlier red CI run came from the merge with Merged current |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🌌 Pull Request Summary
Fixes #10
Problem
When a backup JSON is imported,
importJSONcleaned durations withMath.max(1, parseInt(a.duration, 10) || 30). Because0is falsy, a 0-minute session silently became 30 minutes, inflating logged hours, the productivity score and the Century Club achievement, while-10correctly clamped to1.Root cause
The
|| 30fallback fires for any falsy parsed value, not just missing or non-numeric ones.parseInt("0", 10)is0, so a valid0was replaced by the 30-minute default instead of being clamped to the 1-minute minimum like other out-of-range values.Fix
Fall back to
30only when the parsed value isNaN(missing or non-numeric); otherwise clamp withMath.max(1, …)as before:Imported durations now behave exactly as specified in the issue:
-10 → 1,0 → 1,'abc'/missing →30.Type of Change
How Has This Been Tested?
Extended the existing
clamps progress to 0–100 and keeps durations positivetest intests/storage.test.jsto assert the exact values from the issue's table (-10 → 1,0 → 1,'x' → 30, missing →30). The new assertions failed against the old code (0 became 30) and pass with the fix.npm test: 52/52 pass in 4 timezonesnpm run lint: cleannpm run format:check: clean(The change is in import sanitization only, verified through the unit tests; no UI behavior outside the documented table is affected.)
Contributor Checklist
escapeHTML()to prevent XSS. (n/a — no user-facing HTML changed)CHANGELOG.md)npm run checkpasses locally.docs/DECISIONS.mdanddocs/FLOW.mdneed no updates.