You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @andyra, it looks like there are two separate but related changes in here:
Card.mentioning selects status: published
Search::Record.search joins against the cards table to select status: published
I'll write separately about each.
Card.mentioning
I don't think this change is necessary! Although Card.mentioning by itself will return cards in "draft" status, it's only called in two places.
The first call site is in app/controllers/prompts/cards_controller.rb (used for Lexxy card autocompletion), where it's added to a query that is already filtering for published cards:
The second place is in app/models/filter.rb (which is what's used for the "F"-hotkeyed filter bar), and that is also being added to a query that already filtering for published cards:
So I think this is an unnecessary change -- I don't think there's any way to get draft cards to show up in the "F"-hotkeyed filter bar or the Lexxy autocomplete prompt.
Search::Record.search
Here we do have a problem, and draft cards do show up in the "K"-hotkey search bar.
One way to fix this is to filter for card status at search time, which is what this change implements. And it works (although it doesn't have test coverage yet). But I'm not sure I like that we are introducing a new join against the cards table -- the search query previously just hits the search_records table.
I may be overly paranoid about search performance and maybe this is fine; but I do think we would benefit from keeping the search queries as simple as possible.
So two potential alternatives:
We could add the card status to the search table. One possible advantage here is that drafts are in the search index if we every want to do something with them; but this seems like an unlikely feature and I think YAGNI.
We could delay indexing cards until publish time, so the search index only contains published cards.
I'm leaning towards option 2 here, which is about the same complexity (in my imagination) but feels a bit cleaner to me. WDYT?
See, this is good feedback. And also why prompting Claude to build stuff I can't review myself is maybe not the most direct approach. Thanks for the alternative PR, @flavorjones! Much appreciated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes draft cards from search results