diff --git a/README.md b/README.md index 568561a83f..9cb5f30d47 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ http://localhost:8001/History/downloads.json will return that data as JSON: "total_bytes", ... ], - "table_rows": 576, + "table_rows_count": 576, "rows": [ [ 1, diff --git a/datasette/app.py b/datasette/app.py index 2aade1e4ad..c0ceb3208e 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -385,8 +385,8 @@ async def get(self, request, as_json): )[:5], 'tables_count': len(tables), 'tables_more': len(tables) > 5, - 'table_rows': sum(t['count'] for t in tables), - 'hidden_table_rows': sum(t['count'] for t in hidden_tables), + 'table_rows_sum': sum(t['count'] for t in tables), + 'hidden_table_rows_sum': sum(t['count'] for t in hidden_tables), 'hidden_tables_count': len(hidden_tables), 'views_count': len(info['views']), } @@ -639,11 +639,11 @@ async def data(self, request, name, hash, table): params['search'] = search info = self.ds.inspect() - table_rows = None + table_rows_count = None sortable_columns = set() if not is_view: table_info = info[name]['tables'][table] - table_rows = table_info['count'] + table_rows_count = table_info['count'] sortable_columns = self.sortable_columns_for_table(name, table, use_rowid) # Allow for custom sort order @@ -798,11 +798,11 @@ async def data(self, request, name, hash, table): rows = rows[:self.page_size] # Number of filtered rows in whole set: - filtered_table_rows = None + filtered_table_rows_count = None if count_sql: try: count_rows = list(await self.execute(name, count_sql, params)) - filtered_table_rows = count_rows[0][0] + filtered_table_rows_count = count_rows[0][0] except sqlite3.OperationalError: # Almost certainly hit the timeout pass @@ -858,8 +858,8 @@ async def extra_template(): 'human_description_en': human_description_en, 'rows': rows[:self.page_size], 'truncated': truncated, - 'table_rows': table_rows, - 'filtered_table_rows': filtered_table_rows, + 'table_rows_count': table_rows_count, + 'filtered_table_rows_count': filtered_table_rows_count, 'columns': columns, 'primary_keys': pks, 'query': { diff --git a/datasette/templates/index.html b/datasette/templates/index.html index d1cc0eee6c..cb52740a56 100644 --- a/datasette/templates/index.html +++ b/datasette/templates/index.html @@ -12,9 +12,9 @@
- {{ "{:,}".format(database.table_rows) }} rows in {{ database.tables_count }} table{% if database.tables_count != 1 %}s{% endif %}{% if database.tables_count and database.hidden_tables_count %}, {% endif %} + {{ "{:,}".format(database.table_rows_sum) }} rows in {{ database.tables_count }} table{% if database.tables_count != 1 %}s{% endif %}{% if database.tables_count and database.hidden_tables_count %}, {% endif %} {% if database.hidden_tables_count %} - {{ "{:,}".format(database.hidden_table_rows) }} rows in {{ database.hidden_tables_count }} hidden table{% if database.hidden_tables_count != 1 %}s{% endif %} + {{ "{:,}".format(database.hidden_table_rows_sum) }} rows in {{ database.hidden_tables_count }} hidden table{% if database.hidden_tables_count != 1 %}s{% endif %} {% endif %} {% if database.views_count %} {% if database.tables_count or database.hidden_tables_count %} - {% endif %} diff --git a/datasette/templates/table.html b/datasette/templates/table.html index 56fd47449c..034cab531a 100644 --- a/datasette/templates/table.html +++ b/datasette/templates/table.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ database }}: {{ table }}: {% if filtered_table_rows or filtered_table_rows == 0 %}{{ "{:,}".format(filtered_table_rows) }} row{% if filtered_table_rows == 1 %}{% else %}s{% endif %}{% endif %} +{% block title %}{{ database }}: {{ table }}: {% if filtered_table_rows_count or filtered_table_rows_count == 0 %}{{ "{:,}".format(filtered_table_rows_count) }} row{% if filtered_table_rows_count == 1 %}{% else %}s{% endif %}{% endif %} {% if human_description_en %}where {{ human_description_en }}{% endif %}{% endblock %} {% block extra_head %} @@ -23,8 +23,8 @@