mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Never suggest a facet if it only results in on option
This commit is contained in:
parent
b163b41ddf
commit
bc1bf5c3a1
1 changed files with 5 additions and 4 deletions
|
|
@ -592,17 +592,18 @@ class TableView(RowTableShared):
|
||||||
and_or_where='and' if where_clauses else 'where',
|
and_or_where='and' if where_clauses else 'where',
|
||||||
limit=FACET_LIMIT+1
|
limit=FACET_LIMIT+1
|
||||||
)
|
)
|
||||||
print(suggested_facet_sql)
|
|
||||||
distinct_values = None
|
distinct_values = None
|
||||||
try:
|
try:
|
||||||
distinct_values = await self.execute(
|
distinct_values = await self.execute(
|
||||||
name, suggested_facet_sql, params,
|
name, suggested_facet_sql, params,
|
||||||
truncate=False, custom_time_limit=50
|
truncate=False, custom_time_limit=50
|
||||||
)
|
)
|
||||||
|
num_distinct_values = len(distinct_values)
|
||||||
if (
|
if (
|
||||||
distinct_values and
|
num_distinct_values and
|
||||||
len(distinct_values) <= FACET_LIMIT and
|
num_distinct_values > 1 and
|
||||||
len(distinct_values) < filtered_table_rows_count
|
num_distinct_values <= FACET_LIMIT and
|
||||||
|
num_distinct_values < filtered_table_rows_count
|
||||||
):
|
):
|
||||||
suggested_facets.append({
|
suggested_facets.append({
|
||||||
'name': facet_column,
|
'name': facet_column,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue