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

combine endpoints; deprecate old search endpoint and update readme #346

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

longshuicy
Copy link
Member

No description provided.

@longshuicy longshuicy linked an issue Jan 14, 2025 that may be closed by this pull request

if (queryMap.isEmpty()) {
if (searchText != null && !searchText.isEmpty()) {
Project project = this.projectDAO.getProjectById(searchText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious. Is there any occasion that the searchText is null but searchText is not empty or the other way around?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh the other way, sometimes text could be empty string ""

if (project != null) {
projects.add(project);
} else {
projects = this.projectDAO.searchProjects(searchText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if this projects is also null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the search function will always return list, if not found then empty list.

@Override
    public List<Project> searchProjects(String text) {
        Query<Project> query = this.dataStore.find(Project.class).filter(
            Filters.or(
                Filters.regex(PROJECT_FIELD_NAME).pattern(text).caseInsensitive(),
                Filters.regex(PROJECT_FIELD_DESCRIPTION).pattern(text).caseInsensitive(),
                Filters.regex(PROJECT_FIELD_CREATOR).pattern(text).caseInsensitive(),
                Filters.regex(PROJECT_FIELD_OWNER).pattern(text).caseInsensitive(),
                Filters.regex(PROJECT_FIELD_REGION).pattern(text).caseInsensitive()
            ));
        return query.iterator().toList();
    }
    ```

@longshuicy longshuicy requested a review from ywkim312 January 21, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combine list with filter and search endpoint
2 participants