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

feat: Add dashboard search filter support #112

Merged
merged 9 commits into from
Jun 16, 2020
Merged

Conversation

feng-tao
Copy link
Member

@feng-tao feng-tao commented Jun 9, 2020

Summary of Changes

  1. Include search filter for dashboard
  2. Refactor filter API to be generic with base API
  3. rename search table filter API from search_table to search_table_filter to make it consistent across all entities.

Tests

Add API test and change related backend tests.

Documentation

What documentation did you add or modify and why? Add any relevant links then remove this line

CheckList

Make sure you have checked all steps below to ensure a timely review.

  • PR title addresses the issue accurately and concisely. Example: "Updates the version of Flask to v1.0.2"
  • PR includes a summary of changes.
  • PR adds unit tests, updates existing unit tests, OR documents why no test additions or modifications are needed.
  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain docstrings that explain what it does
  • PR passes make test

@codecov-commenter
Copy link

codecov-commenter commented Jun 9, 2020

Codecov Report

Merging #112 into master will decrease coverage by 0.51%.
The diff coverage is 72.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #112      +/-   ##
==========================================
- Coverage   75.28%   74.76%   -0.52%     
==========================================
  Files          17       18       +1     
  Lines         615      650      +35     
  Branches       77       85       +8     
==========================================
+ Hits          463      486      +23     
- Misses        127      135       +8     
- Partials       25       29       +4     
Impacted Files Coverage Δ
search_service/proxy/elasticsearch.py 73.50% <65.76%> (-3.08%) ⬇️
search_service/api/base.py 92.30% <92.30%> (ø)
search_service/api/dashboard.py 100.00% <100.00%> (ø)
search_service/api/table.py 100.00% <100.00%> (ø)
search_service/proxy/atlas.py 49.03% <100.00%> (ø)
search_service/proxy/base.py 68.18% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a56bea6...e28c2f8. Read the comment docs.

@feng-tao feng-tao changed the title feat: Add search filter support dashboard feat: Add dashboard search filter support Jun 9, 2020
Copy link
Contributor

@ttannis ttannis left a comment

Choose a reason for hiding this comment

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

Some comments and questions.

search_service/__init__.py Show resolved Hide resolved
search_service/__init__.py Show resolved Hide resolved
search_service/api/filter.py Outdated Show resolved Hide resolved
Copy link
Contributor

@jinhyukchang jinhyukchang left a comment

Choose a reason for hiding this comment

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

Good refactoring! Left some comments.

"""
Fetch search results based on the page_index, query_term, and
search_request dictionary posted in the request JSON.
:return: list of table results. List can be empty if query
Copy link
Contributor

Choose a reason for hiding this comment

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

How about updating to: return json payload of schema? Also, from the structure of this generic class, I don't think we can assume it's a list.

return {'message': msg}, HTTPStatus.BAD_REQUEST

query_term = args.get('query_term') # type: str
if ':' in query_term:
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't know this. Why we don't allow this?

Copy link
Member Author

Choose a reason for hiding this comment

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

mostly due to colon is not allowed or needs to escape in doing query string filter.

from search_service.proxy import get_proxy_client


class BaseFilterAPI(Resource):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: how about separate this class into separate file? It just because this file would grow as we introduce more filterable resource.

Comment on lines 22 to 24
schema:
type: integer
default: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Mmm... Not sure what schema with default value 0 is for.

Copy link
Member Author

Choose a reason for hiding this comment

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

copy paste error, will clean up.

index: str = '') -> SearchTableResult:
def fetch_search_results_with_filter(self, *,
query_term: str,
search_request: dict,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we validate if the key is filterable key? For example, if client sends some unknown key, how search service would react?

example: { 'bogus': ['mode'] }

Copy link
Member Author

Choose a reason for hiding this comment

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

@feng-tao
Copy link
Member Author

@jinhyukchang @ttannis update the pr and test it on staging
cc @dikshathakur3119 @Golodhros

Copy link
Contributor

@jinhyukchang jinhyukchang left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the update!

Copy link
Contributor

@ttannis ttannis left a comment

Choose a reason for hiding this comment

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

Previous comments resolved

@feng-tao feng-tao merged commit 17c6739 into master Jun 16, 2020
@feng-tao feng-tao deleted the tfeng_search_filter branch June 16, 2020 18:23
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.

4 participants