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

Configure search_count per resource #2901

Closed
Paul-Bob opened this issue Jun 28, 2024 · 1 comment · Fixed by #2930
Closed

Configure search_count per resource #2901

Paul-Bob opened this issue Jun 28, 2024 · 1 comment · Fixed by #2930
Assignees
Labels
Configuration DSL-related Good first issue Good for newcomers Help wanted We could use some help with this

Comments

@Paul-Bob
Copy link
Contributor

Paul-Bob commented Jun 28, 2024

Context

As a follow up for #2885 lets also enable resource level configuration for the search query limit.

Approach

  1. Fetch the results_count from the search options like we do with the query here
  2. Execute it using Avo::ExecutionContext like we do with the search_query here
  3. Make sure that results_count can be both, an integer or a Proc
  4. Make sure that resource level results_count takes precedence over the global configuration Avo.configuration.search_results_count
  5. Add docs somewhere around here

Final DSL should look like:

class Avo::Resources::User < Avo::BaseResource
  self.search = {
    query: -> { query.ransack(name_eq: params[:q]).result(distinct: false) },
    results_count: -> { user.admin ? 30 : 10 }
  }
end
@Paul-Bob Paul-Bob added Good first issue Good for newcomers Configuration Help wanted We could use some help with this DSL-related labels Jun 28, 2024
@Paul-Bob Paul-Bob assigned Paul-Bob and unassigned Paul-Bob Jun 28, 2024
@binarygit
Copy link
Contributor

Could this be assigned to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Configuration DSL-related Good first issue Good for newcomers Help wanted We could use some help with this
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants