-
-
Notifications
You must be signed in to change notification settings - Fork 48
fix special char in tag search #1098
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @alphatownsman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request addresses an issue where special characters in tag searches were not being handled correctly. The changes involve cleaning up tag titles by removing non-word characters and replacing them with a specified replacement (defaulting to a space). This ensures that tag searches work as expected even when tags contain special characters. The changes affect the JournalQueryParser
in journal/models/index.py
, the to_indexable_doc
method in journal/models/shelf.py
, and the deep_cleanup_title
method in journal/models/tag.py
. Additionally, a print
statement was removed from social/views.py
.
Highlights
- Tag Cleanup: The core change involves using
Tag.deep_cleanup_title
to sanitize tag titles during search and indexing. This function removes non-word characters, ensuring consistent search results. - Journal Query Parser: The
JournalQueryParser
now utilizesTag.deep_cleanup_title
to process tag queries, fixing issues with special characters in tag searches. TheTag
model is imported locally to avoid circular dependencies. - Shelf Indexing: The
to_indexable_doc
method inShelf
model now appliesTag.deep_cleanup_title
to the tags before indexing, ensuring consistency in tag representation.
Changelog
Click here to see the changelog
- journal/models/index.py
- Imported the
Tag
model locally within the__init__
method to avoid potential circular dependencies (line 45). - Modified the tag processing logic to use
Tag.deep_cleanup_title
to clean up tag titles, replacing special characters with underscores (lines 76-79).
- Imported the
- journal/models/shelf.py
- Imported the
Tag
model locally within theto_indexable_doc
method to avoid potential circular dependencies (line 453). - Modified the
to_indexable_doc
method to useTag.deep_cleanup_title
to clean up tag titles before indexing, replacing special characters with underscores (line 475).
- Imported the
- journal/models/tag.py
- Modified the
deep_cleanup_title
method to accept areplacement
argument, allowing control over the character used to replace non-word characters (line 67). The default replacement is a space. - Updated the return statement in
deep_cleanup_title
to strip leading '#' characters (line 70).
- Modified the
- social/views.py
- Removed a
print
statement from the__init__
method of the anonymous class (lines 226).
- Removed a
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A tag's journey,
From chaos to clean index,
Search finds its true form.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request addresses an issue with special characters in tag searches by cleaning up tag titles using the deep_cleanup_title
method. This is a good approach to ensure consistency and prevent errors during searches. The changes look good overall, but I have a few suggestions for improvement.
Summary of Findings
- Import Placement: Consider moving import statements to the top of the files for better readability and dependency tracking.
- Comments for parameters: Adding comments to explain the purpose and usage of parameters like
replacement
indeep_cleanup_title
would improve code understanding. - Missing Test Case: Consider adding a test case to specifically check the behavior of
deep_cleanup_title
with differentreplacement
values. - Debugging Artifact: The
print
statement insocial/views.py
should be removed before merging.
Merge Readiness
The pull request is almost ready for merging. Addressing the comments related to import placement, adding comments for the replacement
parameter, adding a test case for deep_cleanup_title
, and removing the debugging print
statement would improve the code quality and maintainability. I am unable to approve this pull request, and recommend that others review and approve this code before merging.
return ( | ||
re.sub(r"\W+", replacement, title).rstrip().strip("# ").lower()[:100] | ||
or default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.