diff --git a/most_common_nil_fields.rb b/most_common_nil_fields.rb new file mode 100644 index 000000000..53be3cc92 --- /dev/null +++ b/most_common_nil_fields.rb @@ -0,0 +1,17 @@ +blank_attribute_frequencies = Hash.new(0) + +items = LettingsLog.where(status: "in_progress").where("owning_organisation_id >= ?", 4466) +i = 0 +items.each do |item| + LettingsLog.attribute_names.each do |attribute_name| + blank_attribute_frequencies[attribute_name] += 1 if item.send(attribute_name).blank? + end + pp i + i += 1 +end + +most_common_blank_attributes = blank_attribute_frequencies.sort_by { |_, count| -count } + +most_common_blank_attributes.each do |attribute_name, count| + puts "#{attribute_name}: #{count}" +end