Skip to content

Fix three period entry bugs: backup export labels, delete cleanup, flow save#164

Draft
mapgie wants to merge 1 commit into
mainfrom
claude/period-entry-bugs-smzzye
Draft

Fix three period entry bugs: backup export labels, delete cleanup, flow save#164
mapgie wants to merge 1 commit into
mainfrom
claude/period-entry-bugs-smzzye

Conversation

@mapgie

@mapgie mapgie commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Bug 1 (backup export): Full backup export was exporting scaleLabels in the JSON but the import path (importCategoryConfig) called addCategory() and updateCategoryFullSettings() which both lacked a scaleLabels parameter, silently dropping slider labels and slider-scale status on restore. Added the parameter to both functions in TrackingRepository and wired the value through the import path in SettingsViewModel.

  • 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. 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 a TrackingRepository dependency, wired up in MainActivity.

  • Bug 3 (flow save + historical repair): LogPeriodViewModel.save() was hardcoding flowLevel = "" instead of state.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 (runFlowLevelRestoreIfNeeded in GoFloApplication) that reads the flow TrackingLog for each period with a blank flowLevel and writes the resolved label back to PeriodEntry, repairing historic records. Numeric slider values ("1"-"4") are mapped back to their text labels ("Spotting"/"Light"/"Medium"/"Heavy"). Guarded by a new flowLevelRestoreDone preference flag.

Test plan

  • Export a full backup containing a numeric slider category with scale labels; restore it on a clean install and confirm the slider labels and slider-scale status are preserved
  • Log a period with flow and symptoms; delete it from the edit screen; confirm flow, symptoms, and pinned-category tracking logs are all removed
  • Log a period with flow and symptoms; swipe-to-delete from History; confirm the same cleanup occurs; tap Undo and confirm the period is restored (tracking logs are not restored on undo, which is the accepted behaviour)
  • Log a new period; confirm PeriodEntry.flowLevel is non-blank (check via CSV or JSON export)
  • On a device that has periods with blank flowLevel from before this fix, upgrade and confirm the one-time migration restores the correct label from the tracking log

Generated by Claude Code

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants