chore: Minor Housekeeping tasks (#3169)

- Limit Rack attack to production environments
- Make the long-running data migration optional
This commit is contained in:
Sojan Jose 2021-10-08 15:45:45 +05:30 committed by GitHub
parent 1c4afb10df
commit 0e0632be22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 6 deletions

View file

@ -17,7 +17,6 @@ defaults: &defaults
environment: environment:
- CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f - CC_TEST_REPORTER_ID: b1b5c4447bf93f6f0b06a64756e35afd0810ea83649f03971cbf303b4449456f
- RAILS_LOG_TO_STDOUT: false - RAILS_LOG_TO_STDOUT: false
- ENABLE_RACK_ATTACK: false
jobs: jobs:
build: build:
<<: *defaults <<: *defaults

View file

@ -85,4 +85,4 @@ ActiveSupport::Notifications.subscribe('throttle.rack_attack') do |_name, _start
Rails.logger.info "[Rack::Attack][Blocked] remote_ip: \"#{payload[:request].remote_ip}\", path: \"#{payload[:request].path}\"" Rails.logger.info "[Rack::Attack][Blocked] remote_ip: \"#{payload[:request].remote_ip}\", path: \"#{payload[:request].path}\""
end end
Rack::Attack.enabled = ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_RACK_ATTACK', true)) Rack::Attack.enabled = Rails.env.production? ? ActiveModel::Type::Boolean.new.cast(ENV.fetch('ENABLE_RACK_ATTACK', true)) : false

View file

@ -4,12 +4,9 @@ class AddOnlineStatusToAccountUsers < ActiveRecord::Migration[6.1]
t.integer :availability, default: 0, null: false t.integer :availability, default: 0, null: false
t.boolean :auto_offline, default: true, null: false t.boolean :auto_offline, default: true, null: false
end end
update_existing_user_availability
end end
private # run as a seperate data migration if you want to migrate the user statuses
def update_existing_user_availability def update_existing_user_availability
User.find_in_batches do |user_batch| User.find_in_batches do |user_batch|
user_batch.each do |user| user_batch.each do |user|