Skip to content

Commit

Permalink
Rename ?_nofacets=1 to ?_nofacet=1, refs #1353
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jun 2, 2021
1 parent 58d0a00 commit f9655a5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions datasette/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ async def get(self, request, db_name, **kwargs):
async def as_csv(self, request, database, hash, **kwargs):
stream = request.args.get("_stream")
# Do not calculate facets:
if not request.args.get("_nofacets"):
if not request.args.get("_nofacet"):
if not request.query_string:
new_query_string = "_nofacets=1"
new_query_string = "_nofacet=1"
else:
new_query_string = request.query_string + "&_nofacets=1"
new_query_string = request.query_string + "&_nofacet=1"
new_scope = dict(
request.scope, query_string=new_query_string.encode("latin-1")
)
Expand Down
4 changes: 2 additions & 2 deletions datasette/views/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ async def data(
)
)

if not request.args.get("_nofacets"):
if not request.args.get("_nofacet"):
for facet in facet_instances:
(
instance_facet_results,
Expand Down Expand Up @@ -829,7 +829,7 @@ async def data(
self.ds.setting("suggest_facets")
and self.ds.setting("allow_facet")
and not _next
and not request.args.get("_nofacets")
and not request.args.get("_nofacet")
):
for facet in facet_instances:
suggested_facets.extend(await facet.suggest())
Expand Down
2 changes: 1 addition & 1 deletion docs/json_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Special table arguments
``?_facet_size=100``
Increase the number of facet results returned for each facet. Use ``?_facet_size=max`` for the maximum available size, determined by :ref:`setting_max_returned_rows`.

``?_nofacets=1``
``?_nofacet=1``
Disable all facets and facet suggestions for this page, including any defined by :ref:`facets_metadata`.

``?_trace=1``
Expand Down
10 changes: 5 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,13 +1669,13 @@ def test_suggest_facets_off():
assert [] == client.get("/fixtures/facetable.json").json["suggested_facets"]


@pytest.mark.parametrize("nofacets", (True, False))
def test_nofacets(app_client, nofacets):
@pytest.mark.parametrize("nofacet", (True, False))
def test_nofacet(app_client, nofacet):
path = "/fixtures/facetable.json?_facet=state"
if nofacets:
path += "&_nofacets=1"
if nofacet:
path += "&_nofacet=1"
response = app_client.get(path)
if nofacets:
if nofacet:
assert response.json["suggested_facets"] == []
assert response.json["facet_results"] == {}
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def test_custom_sql_csv_blob_columns(app_client):
assert "text/plain; charset=utf-8" == response.headers["content-type"]
assert response.text == (
"rowid,data\r\n"
'1,"http://localhost/fixtures.blob?sql=select+rowid,+data+from+binary_data&_nofacets=1&_blob_column=data&_blob_hash=f3088978da8f9aea479ffc7f631370b968d2e855eeb172bea7f6c7a04262bb6d"\r\n'
'2,"http://localhost/fixtures.blob?sql=select+rowid,+data+from+binary_data&_nofacets=1&_blob_column=data&_blob_hash=b835b0483cedb86130b9a2c280880bf5fadc5318ddf8c18d0df5204d40df1724"\r\n'
'1,"http://localhost/fixtures.blob?sql=select+rowid,+data+from+binary_data&_nofacet=1&_blob_column=data&_blob_hash=f3088978da8f9aea479ffc7f631370b968d2e855eeb172bea7f6c7a04262bb6d"\r\n'
'2,"http://localhost/fixtures.blob?sql=select+rowid,+data+from+binary_data&_nofacet=1&_blob_column=data&_blob_hash=b835b0483cedb86130b9a2c280880bf5fadc5318ddf8c18d0df5204d40df1724"\r\n'
"3,\r\n"
)

Expand Down

0 comments on commit f9655a5

Please sign in to comment.