Skip to content

Commit 3fddbde

Browse files
hsbtclaude
andcommitted
Add reports:backfill_revision task
Fills revision for existing rows by extracting the full commit SHA from ltsv. Intended to run once on Heroku after the column migration. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 185aa24 commit 3fddbde

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

lib/tasks/backfill_revision.rake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace :reports do
2+
desc "Backfill reports.revision with full commit SHA extracted from ltsv"
3+
task :backfill_revision => :environment do
4+
scope = Report.where(revision: nil).where.not(ltsv: nil)
5+
total = scope.count
6+
puts "#{total} reports to scan"
7+
scanned = 0
8+
updated = 0
9+
scope.find_each do |report|
10+
scanned += 1
11+
sha = Report.extract_full_sha(report.ltsv)
12+
if sha
13+
report.update_column(:revision, sha)
14+
updated += 1
15+
end
16+
puts "#{scanned}/#{total} scanned, #{updated} updated" if scanned % 1000 == 0
17+
end
18+
puts "done: #{scanned} scanned, #{updated} updated"
19+
end
20+
end

0 commit comments

Comments
 (0)