-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix API v1 sbd/remastered values, touch parent records on update
- Loading branch information
Showing
6 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class TrackTag < ApplicationRecord | ||
belongs_to :track, counter_cache: :tags_count | ||
belongs_to :track, counter_cache: :tags_count, touch: true | ||
belongs_to :tag, counter_cache: :tracks_count | ||
end |
This file contains 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,21 @@ | ||
namespace :db do | ||
desc "Backfill updated_at timestamps for touch: true associations" | ||
task touch_backfill: :environment do | ||
# Update shows via show_tags | ||
ShowTag.includes(:show).find_each do |show_tag| | ||
show_tag.show&.touch | ||
end | ||
|
||
# Update tracks via track_tags | ||
TrackTag.includes(:track).find_each do |track_tag| | ||
track_tag.track&.touch | ||
end | ||
|
||
# Update shows via tracks | ||
Track.includes(:show).find_each do |track| | ||
track.show&.touch | ||
end | ||
|
||
puts "Backfill complete! Timestamps have been updated." | ||
end | ||
end |
This file contains 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