Maintenance: Increase speed of storage usage calculation.

This commit is contained in:
Martin Edenhofer 2021-03-22 13:35:01 +00:00 committed by Thorsten Eckel
parent 602c8137b4
commit 8e85508fa4
2 changed files with 3 additions and 3 deletions

View file

@ -249,7 +249,7 @@ curl http://localhost/api/v1/monitoring/status?token=XXX
end
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
sql = 'SELECT SUM(CAST(coalesce(size, \'0\') AS INTEGER)) FROM stores WHERE id IN (SELECT MAX(id) FROM stores GROUP BY store_file_id)'
sql = 'SELECT SUM(CAST(coalesce(size, \'0\') AS INTEGER)) FROM stores'
records_array = ActiveRecord::Base.connection.exec_query(sql)
if records_array[0] && records_array[0]['sum']
sum = records_array[0]['sum']

View file

@ -180,8 +180,8 @@ RSpec.describe 'Monitoring', type: :request do
expect(json_response['storage']).to be_truthy
expect(json_response['storage']).to be_key('kB')
# check if the stores got summarized. value should be the same because the file has the same fingerprint
expect(json_response['storage']['kB']).to eq(first_json_response_kb)
# check if the stores got summarized.
expect(json_response['storage']['kB']).to eq(first_json_response_kb * 2)
expect(json_response['storage']).to be_key('MB')
expect(json_response['storage']).to be_key('GB')
else