Fix three period entry bugs: backup export labels, delete cleanup, flow save#164
Draft
mapgie wants to merge 1 commit into
Draft
Fix three period entry bugs: backup export labels, delete cleanup, flow save#164mapgie wants to merge 1 commit into
mapgie wants to merge 1 commit into
Conversation
…ow save Bug 1: Full backup export was missing scaleLabels and slider-scale status for numeric slider categories. Added scaleLabels param to addCategory() and updateCategoryFullSettings() in TrackingRepository, and wired it through the import path in SettingsViewModel.importCategoryConfig(). Bug 2: Deleting a period did not remove its associated tracking logs (flow, symptoms, pinned category logs). Added deleteLogsForCategoryInRange() and deleteLogsForCategoryOnDate() to TrackingLogDao, a deleteLogsForPeriod() helper to TrackingRepository, and called it from both delete paths: LogPeriodViewModel.delete() and HistoryViewModel.stageDeletion(). The HistoryViewModel.Factory now accepts and forwards a TrackingRepository. Bug 3: LogPeriodViewModel.save() was writing flowLevel = "" instead of state.selectedFlowLabel to PeriodEntry, breaking export and doctor-visit display. Fixed the save call. Added a one-time reverse migration (runFlowLevelRestoreIfNeeded) that reads the flow TrackingLog for each period with a blank flowLevel and writes the resolved label back, repairing historic data. Guarded by a new flowLevelRestoreDone preference flag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SYUviWXvsmCQkRGLrRjgD1
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.
Summary
Bug 1 (backup export): Full backup export was exporting
scaleLabelsin the JSON but the import path (importCategoryConfig) calledaddCategory()andupdateCategoryFullSettings()which both lacked ascaleLabelsparameter, silently dropping slider labels and slider-scale status on restore. Added the parameter to both functions inTrackingRepositoryand wired the value through the import path inSettingsViewModel.Bug 2 (delete cleanup): Deleting a period entry (via the edit screen or swipe-to-delete in History) left its associated tracking logs orphaned in
tracking_logs— flow logs for every day of the period, the symptoms log, and any pinned-category logs. AddeddeleteLogsForCategoryInRange()anddeleteLogsForCategoryOnDate()toTrackingLogDao, adeleteLogsForPeriod()helper toTrackingRepository, and called it from both delete paths:LogPeriodViewModel.delete()andHistoryViewModel.stageDeletion(). TheHistoryViewModel.Factorynow accepts aTrackingRepositorydependency, wired up inMainActivity.Bug 3 (flow save + historical repair):
LogPeriodViewModel.save()was hardcodingflowLevel = ""instead ofstate.selectedFlowLabel, breaking JSON/CSV export and the doctor-visit summary for all periods saved during the bug window. Fixed the save call. The tracking log path (syncFlowToTrackingLog) was unaffected and recorded the correct value throughout. Added a one-time reverse migration (runFlowLevelRestoreIfNeededinGoFloApplication) that reads the flowTrackingLogfor each period with a blankflowLeveland writes the resolved label back toPeriodEntry, repairing historic records. Numeric slider values ("1"-"4") are mapped back to their text labels ("Spotting"/"Light"/"Medium"/"Heavy"). Guarded by a newflowLevelRestoreDonepreference flag.Test plan
PeriodEntry.flowLevelis non-blank (check via CSV or JSON export)flowLevelfrom before this fix, upgrade and confirm the one-time migration restores the correct label from the tracking logGenerated by Claude Code