Skip to content

Refactor app structure, fix core timezone bugs, and resolve tracker history loss - #16

Merged
Sparths merged 1 commit into
mainfrom
dev
Apr 24, 2026
Merged

Sparths merged 1 commit into
mainfrom
dev

Conversation

@Sparths

@Sparths Sparths commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Description:
This PR introduces a major reorganization of the codebase for better maintainability while addressing several critical bugs related to tracker history, timezone syncing, and data integrity.

Key Changes & Bug Fixes:

  • Tracker History & Relapse Logic:
    • Fixed an issue where logging a relapse for a "Quit" tracker overwrote the original start_date, completely erasing the user's historical chart data and previous longest streaks.
    • Fixed the bug where cumulative financial savings would incorrectly drop to $0 after a relapse.
    • Replaced the fragile string-matching relapse detection (.includes('relapse')) with a more robust, programmatic approach to prevent false positives in journal entries.
  • Timezone & Date Syncing:
    • Midnight Glitch Fixed: Standardized timezone handling across the frontend so that daily progress bars and historical charts now reset in unison, eliminating the desync between local and UTC time.
    • Log Modal Fixed: Corrected the <input type="datetime-local"> rendering in LogModal.jsx so it no longer inadvertently shifts the logged time based on the user's local timezone offset.
    • Database Consistency: Resolved SQLAlchemy warnings/errors by standardizing how timezone-aware and naive datetimes are handled between models.py and main.py.
  • General Organization:
    • Cleaned up and reorganized the application structure, components, and utility functions to improve readability and future scalability.

- Preserved original start dates on relapse to retain history and streak calculations for "Quit" trackers.
- Resolved local vs. UTC timezone desyncs to prevent the "midnight glitch" in daily progress and streak stats.
- Fixed the `datetime-local` input timezone shifting bug in the Log Modal.
- Replaced fragile string-matching relapse detection with a robust data-driven approach.
- Standardized timezone handling in SQLAlchemy to prevent mixing aware and naive datetimes.
- Fixed cumulative savings calculations so they no longer drop to zero upon relapse.
- Reorganized application structure for better maintainability and cleaner code.
@Sparths
Sparths merged commit 4571c0c into main Apr 24, 2026
2 checks passed
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.

1 participant