Fix modreport dates and recover corrupted timestamps#284
Merged
Conversation
Fixes three issues with the /modreport command:
1. **Date queries**: Changed from MIN/MAX aggregates to explicit ORDER BY +
LIMIT queries for more reliable first/last report dates
2. **Formatting**: Changed channel and reason breakdowns from inline (·-separated)
to newline-separated lists for better readability
3. **Staff breakdown**: Added detailed "Reported By" field showing which staff
members reported the user and how many times
**Migration fixes:**
- Updated 20260218120000_fix_created_at_defaults.ts to recover timestamps from
Discord snowflake IDs instead of destroying data with datetime('now')
- Added 20260220130000_recover_dates_from_snowflakes.ts to recover timestamps
already corrupted in production by the previous destructive migration
Discord snowflake IDs encode creation time in the first 42 bits, allowing us
to recover original timestamps: ((id >> 22) + 1420070400000) / 1000
This fixes the bug where "first reported" was showing today's date instead of
the actual first report date due to migration-time data corruption.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
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
Fixes critical date bugs in
/modreportand recovers timestamps corrupted by migration:Root Cause
The
20260218120000_fix_created_at_defaultsmigration was destructive:default 'CURRENT_TIMESTAMP'stored as literal string instead of functioncreated_at = 'CURRENT_TIMESTAMP'(string)datetime('now'), destroying historical dataSolution
Data Recovery
((id >> 22) + 1420070400000) / 1000log_message_id,thread_idCode Improvements
Test Plan
/modreportshows correct historical dates🤖 Generated with Claude Code