Skip to content

Commit c905b01

Browse files
committed
Fix rake task for Rails 4.2
Rails 4.2 does not preserve the duration type on multiplication: ```ruby x = 5.days # => 5 days x *= 2 # => 864000 ``` This fixes the Rake task so that we use the correct when calculating the timestamp. In order to get the nicely worded output for the duration in the logs we need to re-cast the duration at that point.
1 parent 1f33fa3 commit c905b01

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/tasks/kracken.rake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ namespace :kracken do
55
desc "Remove expired credentials after threshold days " \
66
"(default threshold is 90 days)"
77
task :credentials, %i[threshold] => :environment do |_t, args|
8-
threshold = args.fetch(:threshold) { 90 }.to_i.days
9-
timestamp = threshold.ago
8+
threshold = args.fetch(:threshold) { 90 }.to_i
9+
timestamp = threshold.days.ago
1010
Rails.logger.info "Clearing expired `Credentials` older than " \
11-
"#{threshold.inspect} (#{timestamp})"
11+
"#{threshold.days.inspect} (#{timestamp})"
1212
expired = Credentials.where(expires: true)
1313
.where("expires_at < ?", timestamp)
1414
.destroy_all
1515
.size
1616
Rails.logger.info "Removed: #{expired} credentials"
1717
threshold *= 2
18-
timestamp = threshold.ago
18+
timestamp = threshold.days.ago
1919
Rails.logger.info "Clearing legacy `Credentials` older than " \
20-
"#{threshold.inspect} (#{timestamp})"
20+
"#{threshold.days.inspect} (#{timestamp})"
2121
legacy = Credentials.where(expires: [nil, false])
2222
.where("updated_at < ?", timestamp)
2323
.destroy_all

0 commit comments

Comments
 (0)