We are experiencing issues with streak tracking in our Discord bot deployed on Google Cloud Run. Streaks are not always incrementing correctly, likely due to slow starts or inconsistent updates to the JSON file. This issue requires implementation of validation checks, improved logging, and more robust file operations.
Objectives:
Enhance logging throughout streak-related functions
Implement validation checks for JSON file updates
Use atomic file operations to prevent data corruption
Improve error handling and consistency checks
Tasks:
[ ] Update load_streaks() method:
Add more detailed logging
Improve error handling for file corruption and parsing errors
[ ] Refactor save_streaks() method:
Implement atomic file operations using a temporary file and shutil.move()
Add validation check after saving
[ ] Enhance handle_join() and handle_leave() methods:
Add more detailed logging
Implement better error handling and consistency checks
[ ] Update update_streak() method:
Add more detailed logging for each step of the streak calculation
Improve error handling and edge case management
[ ] Implement a backup system to keep a copy of the previous state before making changes
[ ] Add periodic consistency checks to verify and correct streak data if necessary
[ ] Update unit tests to cover new functionality and edge cases
[ ] Perform thorough testing in a non-production environment
We are experiencing issues with streak tracking in our Discord bot deployed on Google Cloud Run. Streaks are not always incrementing correctly, likely due to slow starts or inconsistent updates to the JSON file. This issue requires implementation of validation checks, improved logging, and more robust file operations.
Objectives:
Tasks:
load_streaks()
method:save_streaks()
method:shutil.move()
handle_join()
andhandle_leave()
methods:update_streak()
method: