Method: PgHero::Methods::Space#capture_space_stats

Defined in:
lib/pghero/methods/space.rb

#capture_space_statsObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/pghero/methods/space.rb', line 122

def capture_space_stats
  now = Time.now
  values =
    relation_sizes.map do |rs|
      {
        database: id,
        schema: rs[:schema],
        relation: rs[:relation],
        size: rs[:size_bytes].to_i,
        captured_at: now
      }
    end
  PgHero::SpaceStats.insert_all!(values) if values.any?
end