From ba027e992ea574a70cfe6d936eec8fa8e854e295 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Tue, 22 Mar 2022 14:52:56 +0530 Subject: [PATCH] Ensure that the values of certain fields are prettified in the statistics tab for collection nodes. Fixes #7216 --- docs/en_US/release_notes_6_8.rst | 1 + .../schemas/tables/partitions/static/js/partition.js | 2 +- .../servers/databases/schemas/tables/static/js/table.js | 4 ++-- .../templates/tables/sql/default/coll_table_stats.sql | 2 +- web/pgadmin/misc/statistics/static/js/Statistics.jsx | 6 ++++++ 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/en_US/release_notes_6_8.rst b/docs/en_US/release_notes_6_8.rst index c36c39406..aa3c9d9bb 100644 --- a/docs/en_US/release_notes_6_8.rst +++ b/docs/en_US/release_notes_6_8.rst @@ -20,5 +20,6 @@ Bug fixes ********* | `Issue #7059 `_ - Fixed an issue where the error is shown on logout when the authentication source is oauth2. + | `Issue #7216 `_ - Ensure that the values of certain fields are prettified in the statistics tab for collection nodes. | `Issue #7238 `_ - Fixed an issue where foreign key is not removed even if the referred table is removed in ERD. | `Issue #7257 `_ - Support running the container under OpenShift with alternate UIDs. \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js index 6836ce30c..7b8b144b9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.js @@ -45,7 +45,7 @@ function( hasSQL: true, hasDepends: true, hasStatistics: true, - statsPrettifyFields: [gettext('Size'), gettext('Indexes size'), gettext('Table size'), + statsPrettifyFields: [gettext('Total Size'), gettext('Indexes size'), gettext('Table size'), gettext('TOAST table size'), gettext('Tuple length'), gettext('Dead tuple length'), gettext('Free space')], sqlAlterHelp: 'sql-altertable.html', diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js index 2e745acbc..9947e06a4 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.js @@ -32,7 +32,7 @@ define('pgadmin.node.table', [ type: 'coll-table', columns: ['name', 'relowner', 'is_partitioned', 'description'], hasStatistics: true, - statsPrettifyFields: [gettext('Size'), gettext('Indexes size'), gettext('Table size'), + statsPrettifyFields: [gettext('Total Size'), gettext('Indexes size'), gettext('Table size'), gettext('TOAST table size'), gettext('Tuple length'), gettext('Dead tuple length'), gettext('Free space')], canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, @@ -48,7 +48,7 @@ define('pgadmin.node.table', [ hasSQL: true, hasDepends: true, hasStatistics: true, - statsPrettifyFields: [gettext('Size'), gettext('Indexes size'), gettext('Table size'), + statsPrettifyFields: [gettext('Total Size'), gettext('Indexes size'), gettext('Table size'), gettext('TOAST table size'), gettext('Tuple length'), gettext('Dead tuple length'), gettext('Free space')], sqlAlterHelp: 'sql-altertable.html', diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/coll_table_stats.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/coll_table_stats.sql index 4cd65f7cb..443d32362 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/coll_table_stats.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/default/coll_table_stats.sql @@ -19,7 +19,7 @@ SELECT + COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) FROM pg_catalog.pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0) END + COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) - FROM pg_catalog.pg_index WHERE indrelid=st.relid)::int8, 0) AS {{ conn|qtIdent(_('Size')) }} + FROM pg_catalog.pg_index WHERE indrelid=st.relid)::int8, 0) AS {{ conn|qtIdent(_('Total Size')) }} FROM pg_catalog.pg_stat_all_tables st JOIN diff --git a/web/pgadmin/misc/statistics/static/js/Statistics.jsx b/web/pgadmin/misc/statistics/static/js/Statistics.jsx index 0d259b6d7..7b3202991 100644 --- a/web/pgadmin/misc/statistics/static/js/Statistics.jsx +++ b/web/pgadmin/misc/statistics/static/js/Statistics.jsx @@ -92,6 +92,12 @@ function getTableData(res, node) { let data = res.data.data; if (node.hasCollectiveStatistics || data['rows'].length > 1) { data.rows.forEach((row) => { + // Prettify the field values + if (!_.isEmpty(node.statsPrettifyFields)) { + node.statsPrettifyFields.forEach((field) => { + row[field] = sizePrettify(row[field]); + }); + }; nodeStats.push({ ...row, icon: '' }); }); colData = getColumn(data.columns, false);