<commit_before># Your Ruby Rack App that returns your Rails App's Health
# Create the file
# "lib/rack/health_check.rb"
# from https://medium.com/@goncalvesjoao/how-to-have-a-working-health-endpoint-while-rails-is-500ring-509efc1da42c

module Rack
  class  HealthCheck
    def call(env)
      status = {
        redis: {
          connected: redis_connected
        },
        postgres: {
          connected: postgres_connected,
          migrations_updated: postgres_migrations_updated
        }
      }

      return [503, {}, [status.to_json]] if !redis_connected || !postgres_connected

      return [200, {}, [status.to_json]]
    end

    protected

    def redis_connected
      Redis.current.ping == 'PONG' rescue false
    end

    def postgres_connected
      begin
        ApplicationRecord.establish_connection
        ApplicationRecord.connection
        ApplicationRecord.connected?
      rescue
        false
      end
    end

    def postgres_migrations_updated
      return false unless postgres_connected

      !ApplicationRecord.connection.migration_context.needs_migration?
    end
  end
end<commit_msg>disable pg healthcheck due to ActiveRecord errors<commit_after># Your Ruby Rack App that returns your Rails App's Health
# Create the file
# "lib/rack/health_check.rb"
# from https://medium.com/@goncalvesjoao/how-to-have-a-working-health-endpoint-while-rails-is-500ring-509efc1da42c

module Rack
  class  HealthCheck
    def call(env)
      status = {
        redis: {
          connected: redis_connected
        }
      }

      return [503, {}, [status.to_json]] if !redis_connected

      return [200, {}, [status.to_json]]
    end

    protected

    def redis_connected
      Redis.current.ping == 'PONG' rescue false
    end
  end
end
{'fraction_non_alphanumeric': 0.08432371250707414, 'fraction_numerical': 0.01697792869269949, 'mean_word_length': 2.6303901437371664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2325890', 'n_tokens_mistral': 564, 'n_tokens_neox': 527, 'n_words': 121}