According to the README [1]: > To mask previously collected IPs, use: > Ahoy::Visit.find_each do |visit| > visit.update_column :ip, Ahoy.mask_ip(visit.ip) > end We're adapting the code with our version, since we use the `Visit` model instead of the `Ahoy::Visit` model. [1] https://github.com/ankane/ahoy/blob/v5.0.2/README.md#ip-masking
19 lines
558 B
Ruby
19 lines
558 B
Ruby
namespace :db do
|
|
desc "Resets the database and loads it from db/dev_seeds.rb"
|
|
task :dev_seed, [:tenant] => [:environment] do |_, args|
|
|
I18n.enforce_available_locales = false
|
|
Tenant.switch(args[:tenant]) { load(Rails.root.join("db", "dev_seeds.rb")) }
|
|
end
|
|
|
|
desc "Mask IPs collected with Ahoy"
|
|
task mask_ips: :environment do
|
|
ApplicationLogger.new.info "Masking tracked IPs collected with Ahoy"
|
|
|
|
Tenant.run_on_each do
|
|
Visit.find_each do |visit|
|
|
visit.update_column :ip, Ahoy.mask_ip(visit.ip)
|
|
end
|
|
end
|
|
end
|
|
end
|