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
b0d2bb3e43
commit
2f81552cd2
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',
|
||||
limit=FACET_LIMIT+1
|
||||
)
|
||||
print(suggested_facet_sql)
|
||||
distinct_values = None
|
||||
try:
|
||||
distinct_values = await self.execute(
|
||||
name, suggested_facet_sql, params,
|
||||
truncate=False, custom_time_limit=50
|
||||
)
|
||||
num_distinct_values = len(distinct_values)
|
||||
if (
|
||||
distinct_values and
|
||||
len(distinct_values) <= FACET_LIMIT and
|
||||
len(distinct_values) < filtered_table_rows_count
|
||||
num_distinct_values and
|
||||
num_distinct_values > 1 and
|
||||
num_distinct_values <= FACET_LIMIT and
|
||||
num_distinct_values < filtered_table_rows_count
|
||||
):
|
||||
suggested_facets.append({
|
||||
'name': facet_column,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue