Added /-/limits and /-/limits.json, closes #270

This commit is contained in:
Simon Willison 2018-05-17 23:16:28 -07:00
commit 39426ff0e4
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
2 changed files with 18 additions and 0 deletions

View file

@ -442,6 +442,10 @@ class Datasette:
JsonDataView.as_view(self, "plugins.json", self.plugins),
"/-/plugins<as_json:(\.json)?$>",
)
app.add_route(
JsonDataView.as_view(self, "limits.json", lambda: self.limits),
"/-/limits<as_json:(\.json)?$>",
)
app.add_route(
DatabaseView.as_view(self), "/<db_name:[^/\.]+?><as_json:(\.jsono?)?$>"
)

View file

@ -897,6 +897,20 @@ def test_versions_json(app_client):
assert 'fts_versions' in response.json['sqlite']
def test_limits_json(app_client):
response = app_client.get(
"/-/limits.json",
gather_request=False
)
assert {
"default_facet_size": 30,
"facet_suggest_time_limit_ms": 50,
"facet_time_limit_ms": 200,
"max_returned_rows": 100,
"sql_time_limit_ms": 200,
} == response.json
def test_page_size_matching_max_returned_rows(app_client_returend_rows_matches_page_size):
fetched = []
path = '/test_tables/no_primary_key.json'