avo icon indicating copy to clipboard operation
avo copied to clipboard

[RFC] Remove the `includes` statement from the search query

Open adrianthedev opened this issue 1 year ago • 7 comments

Context

Some don't need the whole includes statement in the search and that can bring overhead to that particular query.

Proposal

Removing the includes statement from the search[:query] API. Users will still be able to add their own includes statement in the searc[:query] section.

adrianthedev avatar Jul 19 '24 10:07 adrianthedev

@adrianthedev At first sight it seems that self.includes aren't being included in the search query.

Paul-Bob avatar Jul 19 '24 16:07 Paul-Bob

Oh, OK I had a pairing session with @pjmuller and found some eager loading in the logs and thought it was that. Ok. Thanks for checking. I'll close it for now.

adrianthedev avatar Jul 19 '24 18:07 adrianthedev

@adrianthedev & @Paul-Bob: just to clarify, I'm not using the self.includes but the index_query where I'm applying query.includes(). Is that one being used in search?

If not I'll further dig deeper in my codebase why I do see this in my project and create a reproduceable code snippet

pjmuller avatar Jul 20 '24 04:07 pjmuller

Yes @pjmuller the index_query is used on search as the base query and it makes sense.

You are in control of index_query and you can do an early return for the search controller:

  self.index_query = -> do
    return query if controller_name == "search"

    query.order(last_name: :asc)
  end

I'm reopening this issue until you confirm that this works for you.

Paul-Bob avatar Jul 20 '24 06:07 Paul-Bob

This issue has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Aug 05 '24 02:08 github-actions[bot]

@pjmuller any updates on this one?

Paul-Bob avatar Aug 05 '24 06:08 Paul-Bob

This issue has been marked as stale because there was no activity for the past 15 days.

github-actions[bot] avatar Aug 21 '24 02:08 github-actions[bot]

Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️

github-actions[bot] avatar Sep 05 '24 02:09 github-actions[bot]

Apologies for not getting back, I decided to do the searching in a different way so this ticket is not relevant anymore

pjmuller avatar Sep 17 '24 04:09 pjmuller