Skip to content

Commit

Permalink
Querier: Update tests and querier to utilize what_where_key in search.
Browse files Browse the repository at this point in the history
  • Loading branch information
ABPLMC committed May 21, 2024
1 parent 91142cb commit 4dcf15c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions api/datalake_api/querier.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def __init__(self, table_name, latest_table_name=None, dynamodb=None):
self.table_name = table_name
self.latest_table_name = latest_table_name
self.dynamodb = dynamodb
self.use_latest = os.environ.get("DATALAKE_USE_LATEST_TABLE", False)
self.use_latest_table = os.environ.get("DATALAKE_USE_LATEST_TABLE",
False)

def query_by_work_id(self, work_id, what, where=None, cursor=None):
kwargs = self._prepare_work_id_kwargs(work_id, what)
Expand Down Expand Up @@ -340,7 +341,7 @@ def _latest_table(self):
return self.dynamodb.Table(self.latest_table_name)

def query_latest(self, what, where, lookback_days=DEFAULT_LOOKBACK_DAYS):
if self.use_latest:
if self.use_latest_table:
response = self._latest_table.query(
KeyConditionExpression=Key('what_where_key').eq(f'{what}:{where}')
)
Expand Down
2 changes: 1 addition & 1 deletion api/tests/test_archive_querier.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,6 @@ def test_latest_table_query(table_maker, querier, record_maker):
what='boo',
where='hoo{}'.format(i))
table_maker(records)
querier.use_latest = True
querier.use_latest_table = True
result = querier.query_latest('boo', 'hoo0')
_validate_latest_result(result, what='boo', where='hoo0')
2 changes: 1 addition & 1 deletion ingester/datalake_ingester/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, table_name=None, latest_table=None, connection=None):
self.table_name = table_name
self.latest_table_name = os.environ.get("DATALAKE_DNAMODB_LATEST_TABLE",
f"{latest_table}")
self.use_latest = os.environ.get("DATALAKE_USE_LATEST_TABLE", False)
self.use_latest_table = os.environ.get("DATALAKE_USE_LATEST_TABLE", False)
self._prepare_connection(connection)
self.logger = logging.getLogger('storage')

Expand Down

0 comments on commit 4dcf15c

Please sign in to comment.