Skip to content

Instantly share code, notes, and snippets.

View Azdaroth's full-sized avatar

Karol Galanciak Azdaroth

View GitHub Profile
let errorHandlers = {
isAuthenticationError: transitionAway,
IsImportantDataError: showError,
isUnimportantDataError: keepTrying
};
let errorHandler = Object.keys(errorHandlers).find(function(isCurrentError) { isCurrentError(errorFromTryCatch) });
errorHandler(errorFromTryCatch);
class NevacheImport
attr_reader :account, :base_url, :mechanize, :csv_dir, :rentals_csv_file,
:rentals_details_csv_file, :addresses_csv_file
def initialize(account:, csv_dir:)
@account = account
@base_url = "http://www.nevache-tourisme.fr/fr/locations-meubles/"
@mechanize = Mechanize.new
@csv_dir = csv_dir
@rentals_csv_file = File.join(csv_dir, "a_structures.csv")

Before booting the pods

  1. verify the count and schema for all records
old_db_url = ""
new_db_url = ""


connection_klass = Class.new(ApplicationRecord) do
query = "SELECT table_name, column_name FROM information_schema.columns WHERE data_type = 'jsonb';"
result = ActiveRecord::Base.connection.execute(query)
jsonb_aggregate = result.values.to_h.map do |table, column|
jsonb_result = ActiveRecord::Base.connection.execute("SELECT MAX(pg_column_size(#{column})) FROM #{table};").values
if jsonb_result.first
puts "done #{table}, column: #{column}"
{ size: jsonb_result.first, table: table, column: column }
end