-
Notifications
You must be signed in to change notification settings - Fork 26
chore: store release schedule without timezone #878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kitallis
wants to merge
2
commits into
main
Choose a base branch
from
claude/update-train-scheduling-01Sr3QquxMsi23HSFSzwEVSb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
54 changes: 54 additions & 0 deletions
54
db/migrate/20251118165553_change_kickoff_at_to_kickoff_time.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ChangeKickoffAtToKickoffTime < ActiveRecord::Migration[7.0] | ||
| def up | ||
| # Step 1: Add new kickoff_time column (time without timezone) | ||
| add_column :trains, :kickoff_time, :time | ||
|
|
||
| # Step 2: Migrate existing data | ||
| # Convert kickoff_at (UTC datetime) to time in app's timezone | ||
| reversible do |dir| | ||
| dir.up do | ||
| Train.reset_column_information | ||
| Train.find_each do |train| | ||
| next if train.kickoff_at.blank? | ||
|
|
||
| # Convert kickoff_at (UTC) to app's timezone and extract time component | ||
| time_in_app_tz = train.kickoff_at.in_time_zone(train.app.timezone) | ||
| train.update_column(:kickoff_time, time_in_app_tz.strftime("%H:%M:%S")) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # Step 3: Remove old column | ||
| safety_assured { remove_column :trains, :kickoff_at } | ||
| end | ||
|
|
||
| def down | ||
| # Add back the datetime column | ||
| add_column :trains, :kickoff_at, :datetime | ||
|
|
||
| # Attempt to reverse the migration | ||
| # Note: We can't perfectly reverse since we lose the date component | ||
| # We'll set it to the next occurrence from now | ||
| reversible do |dir| | ||
| dir.down do | ||
| Train.reset_column_information | ||
| Train.find_each do |train| | ||
| next if train.kickoff_time.blank? | ||
|
|
||
| # Set to next occurrence from now in app's timezone | ||
| tz = train.app.timezone | ||
| now = Time.current.in_time_zone(tz) | ||
| kickoff_today = tz.parse("#{now.to_date} #{train.kickoff_time}") | ||
| kickoff_datetime = kickoff_today > now ? kickoff_today : kickoff_today + 1.day | ||
|
|
||
| train.update_column(:kickoff_at, kickoff_datetime.utc) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| # Remove the time column | ||
| safety_assured { remove_column :trains, :kickoff_time } | ||
| end | ||
| end | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Down-migration parsing bug for kickoff_time + minor migration cleanup
Two points here:
Down path: malformed parse string (bug)
In the down direction you build the datetime with:
For a
timecolumn,train.kickoff_timewill typically stringify with its own date and zone, so the resulting string is ambiguous (e.g.,"2025-11-19 2000-01-01 11:00:00 UTC"), andtz.parsemay misinterpret or fail. You already do the right thing inTrain#next_run_atby formatting only the time portion.I’d strongly recommend mirroring that here:
Optional: avoid N+1 on app lookups
Both up and down use
Train.find_eachand then hittrain.app.timezone, which will issue an extra query per train. If you expect a large trains table, you can cheaply remove this N+1:Also applies to: 34-52
🏁 Script executed:
Length of output: 1764
🏁 Script executed:
Length of output: 168
🏁 Script executed:
Length of output: 26
🏁 Script executed:
Length of output: 26
🏁 Script executed:
Length of output: 49
🏁 Script executed:
Length of output: 649
🏁 Script executed:
Length of output: 20885
🏁 Script executed:
Length of output: 8379
Down-migration parsing bug for kickoff_time + minor migration cleanup
Two points here:
Down path: malformed parse string (bug)
In the down direction you build the datetime with:
For a
timecolumn,train.kickoff_timewhen interpolated lacks explicit formatting. The codebase consistently usesstrftime("%H:%M:%S")when parsing—as seen inTrain#next_run_at(line 243) and throughout specs. Update to match this pattern:Optional: avoid N+1 on app lookups
Both up and down use
Train.find_eachand then hittrain.app.timezone, which issues an extra query per train. Add eager loading:🤖 Prompt for AI Agents