Only show tables for "public" schema

i.e. avoid the "batch" schema
This commit is contained in:
Lance Edgar 2020-03-15 09:25:10 -05:00
parent 9a61f55f76
commit 59cae7d207

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar # Copyright © 2010-2020 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -52,13 +52,18 @@ class TablesView(MasterView):
""" """
Fetch existing table names and estimate row counts via PG SQL Fetch existing table names and estimate row counts via PG SQL
""" """
# note that we only show 'public' schema tables, i.e. avoid the 'batch'
# schema, at least for now? maybe should include all, plus show the
# schema name within the results grid?
sql = """ sql = """
select schemaname, relname, n_live_tup select relname, n_live_tup
from pg_stat_user_tables from pg_stat_user_tables
where schemaname = 'public'
order by n_live_tup desc; order by n_live_tup desc;
""" """
result = self.Session.execute(sql) result = self.Session.execute(sql)
return [dict(name=row[1], row_count=row[2]) for row in result] return [dict(name=row['relname'], row_count=row['n_live_tup'])
for row in result]
def configure_grid(self, g): def configure_grid(self, g):
g.sorters['name'] = g.make_simple_sorter('name', foldcase=True) g.sorters['name'] = g.make_simple_sorter('name', foldcase=True)