From 48d6dede4a031462183fff559b2dfb4815dc7ac5 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 10 Nov 2020 10:18:07 +0100 Subject: [PATCH] ui: refactor calculate_dedup_factor so that we can reuse this Signed-off-by: Dominik Csapak --- www/Utils.js | 8 ++++++++ www/datastore/Summary.js | 5 +---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/www/Utils.js b/www/Utils.js index 2d0993a3..f678a916 100644 --- a/www/Utils.js +++ b/www/Utils.js @@ -247,6 +247,14 @@ Ext.define('PBS.Utils', { }; }, + calculate_dedup_factor: function(gcstatus) { + let dedup = 1.0; + if (gcstatus['disk-bytes'] > 0) { + dedup = (gcstatus['index-data-bytes'] || 0)/gcstatus['disk-bytes']; + } + return dedup; + }, + constructor: function() { var me = this; diff --git a/www/datastore/Summary.js b/www/datastore/Summary.js index ac3f19e2..5c757e8c 100644 --- a/www/datastore/Summary.js +++ b/www/datastore/Summary.js @@ -57,10 +57,7 @@ Ext.define('PBS.DataStoreInfo', { let gcstatus = store.getById('gc-status').data.value; - let dedup = 1.0; - if (gcstatus['disk-bytes'] > 0) { - dedup = (gcstatus['index-data-bytes'] || 0)/gcstatus['disk-bytes']; - } + let dedup = PBS.Utils.calculate_dedup_factor(gcstatus); let countstext = function(count) { count = count || {};