Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

?_facet_size=X to increase number of facets results on the page #1332

Closed
mroswell opened this issue May 18, 2021 · 5 comments
Closed

?_facet_size=X to increase number of facets results on the page #1332

mroswell opened this issue May 18, 2021 · 5 comments

Comments

@mroswell
Copy link
Sponsor Contributor

Is there a way to add a parameter to the URL to modify default_facet_size?

LIkewise, a way to produce a link on the three dots to expand to all items (or match previous number of items, or add x more)?

@simonw
Copy link
Owner

simonw commented May 23, 2021

A URL parameter to modify that facet size is a really good idea.

I thought I had an issue open for "..." linking to more results but I can't find it now.

@simonw
Copy link
Owner

simonw commented May 23, 2021

?_facet_size=50 seems like a very reasonable thing to support - I'll cap it at whatever the max_returned_rows setting is (which defaults to 1000).

@simonw simonw changed the title Modify default_facet_size via URL parameter? via ellipsis click? ?_facet_size=X to increase number of facets results on the page May 23, 2021
@simonw
Copy link
Owner

simonw commented May 23, 2021

Here's the code in question:

qs_pairs = self.get_querystring_pairs()
facet_size = self.ds.setting("default_facet_size")
for source_and_config in self.get_configs():
config = source_and_config["config"]
source = source_and_config["source"]
column = config.get("column") or config["simple"]
facet_sql = """
select {col} as value, count(*) as count from (
{sql}
)
where {col} is not null
group by {col} order by count desc, value limit {limit}
""".format(
col=escape_sqlite(column), sql=self.sql, limit=facet_size + 1
)
try:
facet_rows_results = await self.ds.execute(
self.database,
facet_sql,
self.params,
truncate=False,
custom_time_limit=self.ds.setting("facet_time_limit_ms"),
)

It has access to the current request object as self.request.

@simonw simonw closed this as completed in 9789b94 May 23, 2021
@simonw
Copy link
Owner

simonw commented May 23, 2021

Documentation:

simonw added a commit that referenced this issue May 23, 2021
simonw added a commit that referenced this issue May 27, 2021
@simonw
Copy link
Owner

simonw commented May 27, 2021

simonw added a commit that referenced this issue Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants