diff options
| author | Zog | 2018-01-17 16:57:59 +0100 |
|---|---|---|
| committer | Zog | 2018-01-17 16:57:59 +0100 |
| commit | b853120644819dd1ae646ea762f457836abfea09 (patch) | |
| tree | 29770024a36dfc9b9e697e014ddc25c0b7b32a68 /lib/tasks | |
| parent | e36dcdd912b28eb69fa14ee7c830d717b9c9300a (diff) | |
| download | chouette-core-b853120644819dd1ae646ea762f457836abfea09.tar.bz2 | |
Refs #5593 @1h;
- Register all models that implement checksums
- Add a simple rake task that updates all checksums within a given
referential
Diffstat (limited to 'lib/tasks')
| -rw-r--r-- | lib/tasks/referential.rake | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/tasks/referential.rake b/lib/tasks/referential.rake index 7bab6e040..1b46f69f0 100644 --- a/lib/tasks/referential.rake +++ b/lib/tasks/referential.rake @@ -67,4 +67,31 @@ namespace :referential do referential.update(ready: true) end end + + desc 'Update all the checksums in the given referential' + task :update_checksums_in_referential, [:slug] => :environment do |t, args| + thing = %w(\\ | / —) + Referential.force_register_models_with_checksum if Rails.env.development? + referential = Referential.find_by_slug(args[:slug]) + referential.switch do + Referential.models_with_checksum.each do |klass| + i = 0 + j = 0 + prev_size = 1 + print "Updating checksums for #{klass.name}: " + count = klass.count + klass.find_each do |o| + o.update_checksum! + if j%10 == 0 + out = "#{"\b"*prev_size}\e[33m#{thing[i]}\e[0m (#{j}/#{count})" + prev_size = out.size - prev_size - 9 + print out + i = (i+1) % thing.size + end + j += 1 + end + print "#{"\b"*prev_size}\e[32m✓\e[0m (#{count}/#{count})\n" + end + end + end end |
