Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
get_all
Method in db.py to Retrieve All Items from DynamoDB …
…Table (#642) This update modifies the `get_all` method to ensure that all items from the DynamoDB table are retrieved during a scan operation. **Reason for Change:** In Lab 4, `unranked_product_ids` are pulled from the `featured` items table, subsequently used to obtain a ranked list of products from "all" products via AWS Personalize. The existing `get_all` method's use of DynamoDB's scan operation only retrieves a limited subset of items by default, thus the ranked list may contain fewer items than the unranked list depending what's available in the fraction of the products table returned by the scan. This makes side-by-side comparisons of these lists difficult. This modification will ensure that all items are fetched through a paginated retrieval of data. **Updated `get_all` function: ``` def get_all(self): items = [] response = self.table.scan() while 'LastEvaluatedKey' in response: items.extend(response['Items']) response = self.table.scan(ExclusiveStartKey=response['LastEvaluatedKey']) items.extend(response['Items']) return items ``` Thus every item in the DynamoDB table is fetched before any operations that require a complete dataset, such as generating personalized rankings.
- Loading branch information