Ensure that the values of certain fields are prettified in the statistics tab for collection nodes. Fixes #7216

This commit is contained in:
Akshay Joshi 2022-03-22 14:52:56 +05:30
parent e7dc6df723
commit ba027e992e
5 changed files with 11 additions and 4 deletions

View File

@ -20,5 +20,6 @@ Bug fixes
********* *********
| `Issue #7059 <https://redmine.postgresql.org/issues/7059>`_ - Fixed an issue where the error is shown on logout when the authentication source is oauth2. | `Issue #7059 <https://redmine.postgresql.org/issues/7059>`_ - Fixed an issue where the error is shown on logout when the authentication source is oauth2.
| `Issue #7216 <https://redmine.postgresql.org/issues/7216>`_ - Ensure that the values of certain fields are prettified in the statistics tab for collection nodes.
| `Issue #7238 <https://redmine.postgresql.org/issues/7238>`_ - Fixed an issue where foreign key is not removed even if the referred table is removed in ERD. | `Issue #7238 <https://redmine.postgresql.org/issues/7238>`_ - Fixed an issue where foreign key is not removed even if the referred table is removed in ERD.
| `Issue #7257 <https://redmine.postgresql.org/issues/7257>`_ - Support running the container under OpenShift with alternate UIDs. | `Issue #7257 <https://redmine.postgresql.org/issues/7257>`_ - Support running the container under OpenShift with alternate UIDs.

View File

@ -45,7 +45,7 @@ function(
hasSQL: true, hasSQL: true,
hasDepends: true, hasDepends: true,
hasStatistics: 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('TOAST table size'), gettext('Tuple length'),
gettext('Dead tuple length'), gettext('Free space')], gettext('Dead tuple length'), gettext('Free space')],
sqlAlterHelp: 'sql-altertable.html', sqlAlterHelp: 'sql-altertable.html',

View File

@ -32,7 +32,7 @@ define('pgadmin.node.table', [
type: 'coll-table', type: 'coll-table',
columns: ['name', 'relowner', 'is_partitioned', 'description'], columns: ['name', 'relowner', 'is_partitioned', 'description'],
hasStatistics: 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('TOAST table size'), gettext('Tuple length'),
gettext('Dead tuple length'), gettext('Free space')], gettext('Dead tuple length'), gettext('Free space')],
canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema, canDrop: SchemaChildTreeNode.isTreeItemOfChildOfSchema,
@ -48,7 +48,7 @@ define('pgadmin.node.table', [
hasSQL: true, hasSQL: true,
hasDepends: true, hasDepends: true,
hasStatistics: 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('TOAST table size'), gettext('Tuple length'),
gettext('Dead tuple length'), gettext('Free space')], gettext('Dead tuple length'), gettext('Free space')],
sqlAlterHelp: 'sql-altertable.html', sqlAlterHelp: 'sql-altertable.html',

View File

@ -19,7 +19,7 @@ SELECT
+ COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) + COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid))
FROM pg_catalog.pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0) END FROM pg_catalog.pg_index WHERE indrelid=cl.reltoastrelid)::int8, 0) END
+ COALESCE((SELECT SUM(pg_catalog.pg_relation_size(indexrelid)) + 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 FROM
pg_catalog.pg_stat_all_tables st pg_catalog.pg_stat_all_tables st
JOIN JOIN

View File

@ -92,6 +92,12 @@ function getTableData(res, node) {
let data = res.data.data; let data = res.data.data;
if (node.hasCollectiveStatistics || data['rows'].length > 1) { if (node.hasCollectiveStatistics || data['rows'].length > 1) {
data.rows.forEach((row) => { 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: '' }); nodeStats.push({ ...row, icon: '' });
}); });
colData = getColumn(data.columns, false); colData = getColumn(data.columns, false);