mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fixed bug with human filter description, refs #189
We were showing this:
201 rows where sorted by sortable_with_nulls
We now show this:
201 rows sorted by sortable_with_nulls
This commit is contained in:
parent
23e0fdb0f3
commit
c1d37fdf2b
3 changed files with 7 additions and 2 deletions
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
{% if filtered_table_rows or human_description_en %}
|
{% 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 %}
|
<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 human_description_en %}where {{ human_description_en }}{% endif %}
|
{% if human_description_en %}{{ human_description_en }}{% endif %}
|
||||||
</h3>
|
</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -475,7 +475,10 @@ class Filters:
|
||||||
and_bits.append(', '.join(commas))
|
and_bits.append(', '.join(commas))
|
||||||
if tail:
|
if tail:
|
||||||
and_bits.append(tail[0])
|
and_bits.append(tail[0])
|
||||||
return ' and '.join(and_bits)
|
s = ' and '.join(and_bits)
|
||||||
|
if not s:
|
||||||
|
return ''
|
||||||
|
return 'where {}'.format(s)
|
||||||
|
|
||||||
def selections(self):
|
def selections(self):
|
||||||
"Yields (column, lookup, value) tuples"
|
"Yields (column, lookup, value) tuples"
|
||||||
|
|
|
||||||
|
|
@ -388,6 +388,8 @@ def test_sortable_and_filtered(app_client):
|
||||||
)
|
)
|
||||||
response = app_client.get(path, gather_request=False)
|
response = app_client.get(path, gather_request=False)
|
||||||
fetched = response.json['rows']
|
fetched = response.json['rows']
|
||||||
|
assert 'where content contains "d" sorted by sortable descending' \
|
||||||
|
== response.json['human_description_en']
|
||||||
expected = [
|
expected = [
|
||||||
row for row in generate_sortable_rows(201)
|
row for row in generate_sortable_rows(201)
|
||||||
if 'd' in row['content']
|
if 'd' in row['content']
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue