lib/pghero/methods/sequences.rb in pghero-1.7.0 vs lib/pghero/methods/sequences.rb in pghero-2.0.0
- old
+ new
@@ -19,19 +19,18 @@
AND table_catalog = current_database()
ORDER BY
sequence_name ASC
SQL
- select_all(sequences.map { |s| "SELECT last_value FROM #{s["sequence"]}" }.join(" UNION ALL ")).each_with_index do |row, i|
- sequences[i]["last_value"] = row["last_value"]
+ select_all(sequences.map { |s| "SELECT last_value FROM #{s[:sequence]}" }.join(" UNION ALL ")).each_with_index do |row, i|
+ sequences[i][:last_value] = row[:last_value]
end
sequences
end
- def sequence_danger(options = {})
- threshold = (options[:threshold] || 0.9).to_f
- sequences.select { |s| s["last_value"].to_i / s["max_value"].to_f > threshold }.sort_by { |s| s["max_value"].to_i - s["last_value"].to_i }
+ def sequence_danger(threshold: 0.9)
+ sequences.select { |s| s[:last_value] / s[:max_value].to_f > threshold }.sort_by { |s| s[:max_value] - s[:last_value] }
end
end
end
end