Unverified Commit 524bc07b authored by Josh Howard's avatar Josh Howard Committed by GitHub

Added frontend configuration options for personalized popular tables. (#789)

Signed-off-by: 's avatarJosh Howard <joshthoward@gmail.com>
parent 556b7ecd
...@@ -26,7 +26,7 @@ metadata_blueprint = Blueprint('metadata', __name__, url_prefix='/api/metadata/v ...@@ -26,7 +26,7 @@ metadata_blueprint = Blueprint('metadata', __name__, url_prefix='/api/metadata/v
TABLE_ENDPOINT = '/table' TABLE_ENDPOINT = '/table'
LAST_INDEXED_ENDPOINT = '/latest_updated_ts' LAST_INDEXED_ENDPOINT = '/latest_updated_ts'
POPULAR_TABLES_ENDPOINT = '/popular_tables/' POPULAR_TABLES_ENDPOINT = '/popular_tables'
TAGS_ENDPOINT = '/tags/' TAGS_ENDPOINT = '/tags/'
USER_ENDPOINT = '/user' USER_ENDPOINT = '/user'
DASHBOARD_ENDPOINT = '/dashboard' DASHBOARD_ENDPOINT = '/dashboard'
...@@ -56,9 +56,14 @@ def popular_tables() -> Response: ...@@ -56,9 +56,14 @@ def popular_tables() -> Response:
https://github.com/lyft/amundsenmetadatalibrary/blob/master/metadata_service/api/popular_tables.py https://github.com/lyft/amundsenmetadatalibrary/blob/master/metadata_service/api/popular_tables.py
""" """
try: try:
if app.config['AUTH_USER_METHOD'] and app.config['POPULAR_TABLE_PERSONALIZATION']:
user_id = app.config['AUTH_USER_METHOD'](app).user_id
else:
user_id = ''
service_base = app.config['METADATASERVICE_BASE'] service_base = app.config['METADATASERVICE_BASE']
count = app.config['POPULAR_TABLE_COUNT'] count = app.config['POPULAR_TABLE_COUNT']
url = f'{service_base}{POPULAR_TABLES_ENDPOINT}?limit={count}' url = f'{service_base}{POPULAR_TABLES_ENDPOINT}/{user_id}?limit={count}'
response = request_metadata(url=url) response = request_metadata(url=url)
status_code = response.status_code status_code = response.status_code
......
...@@ -38,6 +38,8 @@ class Config: ...@@ -38,6 +38,8 @@ class Config:
# Number of popular tables to be displayed on the index/search page # Number of popular tables to be displayed on the index/search page
POPULAR_TABLE_COUNT = 4 # type: int POPULAR_TABLE_COUNT = 4 # type: int
# Personalize the popular tables response for the current authenticated user
POPULAR_TABLE_PERSONALIZATION = False # type: bool
# Request Timeout Configurations in Seconds # Request Timeout Configurations in Seconds
REQUEST_SESSION_TIMEOUT_SEC = 3 REQUEST_SESSION_TIMEOUT_SEC = 3
...@@ -155,6 +157,7 @@ class LocalConfig(Config): ...@@ -155,6 +157,7 @@ class LocalConfig(Config):
class TestConfig(LocalConfig): class TestConfig(LocalConfig):
POPULAR_TABLE_PERSONALIZATION = True
AUTH_USER_METHOD = get_test_user AUTH_USER_METHOD = get_test_user
NOTIFICATIONS_ENABLED = True NOTIFICATIONS_ENABLED = True
ISSUE_TRACKER_URL = 'test_url' ISSUE_TRACKER_URL = 'test_url'
......
...@@ -476,7 +476,10 @@ class MetadataTest(unittest.TestCase): ...@@ -476,7 +476,10 @@ class MetadataTest(unittest.TestCase):
Test successful popular_tables request Test successful popular_tables request
:return: :return:
""" """
responses.add(responses.GET, local_app.config['METADATASERVICE_BASE'] + POPULAR_TABLES_ENDPOINT, mock_url = local_app.config['METADATASERVICE_BASE'] \
+ POPULAR_TABLES_ENDPOINT \
+ f'/{TEST_USER_ID}'
responses.add(responses.GET, mock_url,
json=self.mock_popular_tables, status=HTTPStatus.OK) json=self.mock_popular_tables, status=HTTPStatus.OK)
with local_app.test_client() as test: with local_app.test_client() as test:
...@@ -492,7 +495,10 @@ class MetadataTest(unittest.TestCase): ...@@ -492,7 +495,10 @@ class MetadataTest(unittest.TestCase):
returned to the React application returned to the React application
:return: :return:
""" """
responses.add(responses.GET, local_app.config['METADATASERVICE_BASE'] + POPULAR_TABLES_ENDPOINT, mock_url = local_app.config['METADATASERVICE_BASE'] \
+ POPULAR_TABLES_ENDPOINT \
+ f'/{TEST_USER_ID}'
responses.add(responses.GET, mock_url,
json=self.mock_popular_tables, status=HTTPStatus.BAD_REQUEST) json=self.mock_popular_tables, status=HTTPStatus.BAD_REQUEST)
with local_app.test_client() as test: with local_app.test_client() as test:
...@@ -506,7 +512,10 @@ class MetadataTest(unittest.TestCase): ...@@ -506,7 +512,10 @@ class MetadataTest(unittest.TestCase):
results from the metadata service results from the metadata service
:return: :return:
""" """
responses.add(responses.GET, local_app.config['METADATASERVICE_BASE'] + POPULAR_TABLES_ENDPOINT, mock_url = local_app.config['METADATASERVICE_BASE'] \
+ POPULAR_TABLES_ENDPOINT \
+ f'/{TEST_USER_ID}'
responses.add(responses.GET, mock_url,
json={'popular_tables': None}, status=HTTPStatus.OK) json={'popular_tables': None}, status=HTTPStatus.OK)
with local_app.test_client() as test: with local_app.test_client() as test:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment