Rename filtered_table_rows_count to count, refs #782

pull/1974/head
Simon Willison 2022-12-31 12:52:57 -08:00
rodzic a2dca62360
commit 5bbe2bcc50
5 zmienionych plików z 14 dodań i 13 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% 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 %} {{ human_description_en }}{% endif %}{% endblock %}
{% block title %}{{ database }}: {{ table }}: {% if count or count == 0 %}{{ "{:,}".format(count) }} row{% if count == 1 %}{% else %}s{% endif %}{% endif %}{% if human_description_en %} {{ human_description_en }}{% endif %}{% endblock %}
{% block extra_head %}
{{- super() -}}
@ -55,8 +55,8 @@
</dl>
{% 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 count or human_description_en %}
<h3>{% if count or count == 0 %}{{ "{:,}".format(count) }} row{% if count == 1 %}{% else %}s{% endif %}{% endif %}
{% if human_description_en %}{{ human_description_en }}{% endif %}
</h3>
{% endif %}

Wyświetl plik

@ -539,7 +539,7 @@ class TableView(DataView):
results = await db.execute(sql, params, truncate=True, **extra_args)
# Calculate the total count for this query
filtered_table_rows_count = None
count = None
if (
not db.is_mutable
and self.ds.inspect_data
@ -547,17 +547,17 @@ class TableView(DataView):
):
# We can use a previously cached table row count
try:
filtered_table_rows_count = self.ds.inspect_data[database_name][
count = self.ds.inspect_data[database_name][
"tables"
][table_name]["count"]
except KeyError:
pass
# Otherwise run a select count(*) ...
if count_sql and filtered_table_rows_count is None and not nocount:
if count_sql and count is None and not nocount:
try:
count_rows = list(await db.execute(count_sql, from_sql_params))
filtered_table_rows_count = count_rows[0][0]
count = count_rows[0][0]
except QueryInterrupted:
pass
@ -584,7 +584,7 @@ class TableView(DataView):
params=params,
table=table_name,
metadata=table_metadata,
row_count=filtered_table_rows_count,
row_count=count,
)
)
@ -853,7 +853,7 @@ class TableView(DataView):
"human_description_en": human_description_en,
"rows": rows[:page_size],
"truncated": results.truncated,
"filtered_table_rows_count": filtered_table_rows_count,
"count": count,
"expanded_columns": expanded_columns,
"expandable_columns": expandable_columns,
"columns": columns,

Wyświetl plik

@ -38,6 +38,7 @@ looks like this::
"value": "Pinus radiata :: Monterey Pine"
}
],
"count": 195002,
"truncated": false,
"next": "100",
"next_url": "http://127.0.0.1:8001/sf-trees-02c8ef1/qSpecies.json?_next=100",

Wyświetl plik

@ -981,7 +981,7 @@ def test_common_prefix_database_names(app_client_conflicting_database_names):
def test_inspect_file_used_for_count(app_client_immutable_and_inspect_file):
response = app_client_immutable_and_inspect_file.get("/fixtures/sortable.json")
assert response.json["filtered_table_rows_count"] == 100
assert response.json["count"] == 100
@pytest.mark.asyncio

Wyświetl plik

@ -233,7 +233,7 @@ async def test_page_size_zero(ds_client):
response = await ds_client.get("/fixtures/no_primary_key.json?_size=0")
assert response.status_code == 200
assert [] == response.json()["rows"]
assert 201 == response.json()["filtered_table_rows_count"]
assert 201 == response.json()["count"]
assert None is response.json()["next"]
assert None is response.json()["next_url"]
@ -346,7 +346,7 @@ async def test_sortable_and_filtered(ds_client):
== response.json()["human_description_en"]
)
expected = [row for row in generate_sortable_rows(201) if "d" in row["content"]]
assert len(expected) == response.json()["filtered_table_rows_count"]
assert len(expected) == response.json()["count"]
expected.sort(key=lambda row: -row["sortable"])
assert [r["content"] for r in expected] == [r["content"] for r in fetched]
@ -997,7 +997,7 @@ async def test_nocount(ds_client, nocount, expected_count):
if nocount:
path += "?_nocount=1"
response = await ds_client.get(path)
assert response.json()["filtered_table_rows_count"] == expected_count
assert response.json()["count"] == expected_count
def test_nocount_nofacet_if_shape_is_object(app_client_with_trace):