mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
table_rows => table_rows_count, filtered_table_rows => filtered_table_rows_count
Renamed properties. Closes #194
This commit is contained in:
parent
c1d37fdf2b
commit
a290f28caa
6 changed files with 17 additions and 15 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -385,8 +385,8 @@ class IndexView(RenderMixin):
|
|||
)[: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 @@ class TableView(RowTableShared):
|
|||
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 @@ class TableView(RowTableShared):
|
|||
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 @@ class TableView(RowTableShared):
|
|||
'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': {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
{% for database in databases %}
|
||||
<h2 style="padding-left: 10px; border-left: 10px solid #{{ database.hash[:6] }}"><a href="{{ database.path }}">{{ database.name }}</a></h2>
|
||||
<p>
|
||||
{{ "{:,}".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 %}
|
||||
|
|
|
|||
|
|
@ -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 @@
|
|||
|
||||
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}
|
||||
|
||||
{% if filtered_table_rows or human_description_en %}
|
||||
<h3>{% if filtered_table_rows or filtered_table_rows == 0 %}{{ "{:,}".format(filtered_table_rows) }} row{% if filtered_table_rows == 1 %}{% else %}s{% endif %}{% endif %}
|
||||
{% if filtered_table_rows_count or human_description_en %}
|
||||
<h3>{% 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 %}{{ human_description_en }}{% endif %}
|
||||
</h3>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ JSON:
|
|||
"total_bytes",
|
||||
...
|
||||
],
|
||||
"table_rows": 576,
|
||||
"table_rows_count": 576,
|
||||
"rows": [
|
||||
[
|
||||
1,
|
||||
|
|
|
|||
|
|
@ -394,6 +394,8 @@ def test_sortable_and_filtered(app_client):
|
|||
row for row in generate_sortable_rows(201)
|
||||
if 'd' in row['content']
|
||||
]
|
||||
assert len(expected) == response.json['filtered_table_rows_count']
|
||||
assert 201 == response.json['table_rows_count']
|
||||
expected.sort(key=lambda row: -row['sortable'])
|
||||
assert [
|
||||
r['content'] for r in expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue