Maintenance: Increase speed of storage usage calculation.
This commit is contained in:
parent
602c8137b4
commit
8e85508fa4
2 changed files with 3 additions and 3 deletions
|
@ -249,7 +249,7 @@ curl http://localhost/api/v1/monitoring/status?token=XXX
|
||||||
end
|
end
|
||||||
|
|
||||||
if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
|
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)
|
records_array = ActiveRecord::Base.connection.exec_query(sql)
|
||||||
if records_array[0] && records_array[0]['sum']
|
if records_array[0] && records_array[0]['sum']
|
||||||
sum = records_array[0]['sum']
|
sum = records_array[0]['sum']
|
||||||
|
|
|
@ -180,8 +180,8 @@ RSpec.describe 'Monitoring', type: :request do
|
||||||
expect(json_response['storage']).to be_truthy
|
expect(json_response['storage']).to be_truthy
|
||||||
expect(json_response['storage']).to be_key('kB')
|
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
|
# check if the stores got summarized.
|
||||||
expect(json_response['storage']['kB']).to eq(first_json_response_kb)
|
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('MB')
|
||||||
expect(json_response['storage']).to be_key('GB')
|
expect(json_response['storage']).to be_key('GB')
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue