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
TABLE_ENDPOINT = '/table'
LAST_INDEXED_ENDPOINT = '/latest_updated_ts'
POPULAR_TABLES_ENDPOINT = '/popular_tables/'
POPULAR_TABLES_ENDPOINT = '/popular_tables'
TAGS_ENDPOINT = '/tags/'
USER_ENDPOINT = '/user'
DASHBOARD_ENDPOINT = '/dashboard'
......@@ -56,9 +56,14 @@ def popular_tables() -> Response:
https://github.com/lyft/amundsenmetadatalibrary/blob/master/metadata_service/api/popular_tables.py
"""
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']
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)
status_code = response.status_code
......
......@@ -38,6 +38,8 @@ class Config:
# Number of popular tables to be displayed on the index/search page
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_SESSION_TIMEOUT_SEC = 3
......@@ -155,6 +157,7 @@ class LocalConfig(Config):
class TestConfig(LocalConfig):
POPULAR_TABLE_PERSONALIZATION = True
AUTH_USER_METHOD = get_test_user
NOTIFICATIONS_ENABLED = True
ISSUE_TRACKER_URL = 'test_url'
......
......@@ -476,7 +476,10 @@ class MetadataTest(unittest.TestCase):
Test successful popular_tables request
: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)
with local_app.test_client() as test:
......@@ -492,7 +495,10 @@ class MetadataTest(unittest.TestCase):
returned to the React application
: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)
with local_app.test_client() as test:
......@@ -506,7 +512,10 @@ class MetadataTest(unittest.TestCase):
results from the metadata service
: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)
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