Fix tablespace statistics. Fixes #1196

This commit is contained in:
Murtuza Zabuawala 2016-06-23 13:06:05 +01:00 committed by Dave Page
parent 8b0e65dc57
commit e4ef927da3
4 changed files with 18 additions and 11 deletions

View File

@ -558,16 +558,15 @@ class TablespaceView(PGChildNodeView):
"/".join([self.template_path, 'stats.sql']),
tsid=tsid, conn=self.conn
)
status, res = self.conn.execute_scalar(SQL)
status, res = self.conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
# TODO:// Format & return output of stats call accordingly
# TODO:// for now it's hardcoded as below
result = 'Tablespace Size: {0}'.format(res)
return ajax_response(response=result)
return make_json_response(
data=res,
status=200
)
@check_precondition
def dependencies(self, gid, sid, tsid):

View File

@ -8,7 +8,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
node: 'tablespace',
label: '{{ _('Tablespaces') }}',
type: 'coll-tablespace',
columns: ['name', 'spcuser', 'description']
columns: ['name', 'spcuser', 'description'],
hasStatistics: true
});
};
@ -23,6 +24,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
hasSQL: true,
canDrop: true,
hasDepends: true,
hasStatistics: true,
Init: function() {
/* Avoid mulitple registration of menus */
if (this.initialized)

View File

@ -1,6 +1,9 @@
{### SQL to fetch tablespace object stats ###}
{% if tsid %}
SELECT pg_size_pretty(pg_tablespace_size({{ tsid|qtLiteral }}::OID)) AS size
SELECT pg_size_pretty(pg_tablespace_size({{ tsid|qtLiteral }}::OID)) AS {{ conn|qtIdent(_('Size')) }}
{% else %}
SELECT ts.spcname as name, pg_size_pretty(pg_tablespace_size(ts.oid)) AS size FROM pg_catalog.pg_tablespace ts;
SELECT ts.spcname AS {{ conn|qtIdent(_('Name')) }},
pg_size_pretty(pg_tablespace_size(ts.oid)) AS {{ conn|qtIdent(_('Size')) }}
FROM
pg_catalog.pg_tablespace ts;
{% endif %}

View File

@ -1,6 +1,9 @@
{### SQL to fetch tablespace object stats ###}
{% if tsid %}
SELECT pg_size_pretty(pg_tablespace_size({{ qtLiteral(tsid) }}::OID)) AS size
SELECT pg_size_pretty(pg_tablespace_size({{ tsid|qtLiteral }}::OID)) AS {{ conn|qtIdent(_('Size')) }}
{% else %}
SELECT ts.spcname as name, pg_size_pretty(pg_tablespace_size(ts.oid)) AS size FROM pg_catalog.pg_tablespace ts;
SELECT ts.spcname AS {{ conn|qtIdent(_('Name')) }},
pg_size_pretty(pg_tablespace_size(ts.oid)) AS {{ conn|qtIdent(_('Size')) }}
FROM
pg_catalog.pg_tablespace ts;
{% endif %}