mirror of
https://github.com/Sea-Haven-Industries/procurement-ingest.git
synced 2026-10-03 15:03:12 +00:00
Add pagination to WO web UI scan
get_work_orders() only fetched the first 1MB page from DynamoDB. Loop on LastEvaluatedKey to match the PO web UI pattern.
This commit is contained in:
parent
78eb8de067
commit
afcd0eabe2
1 changed files with 5 additions and 2 deletions
|
|
@ -18,9 +18,12 @@ COMMENTS_TABLE = os.environ.get("COMMENTS_TABLE", "WorkOrderComments")
|
||||||
|
|
||||||
def get_work_orders():
|
def get_work_orders():
|
||||||
table = dynamodb.Table(WORK_ORDERS_TABLE)
|
table = dynamodb.Table(WORK_ORDERS_TABLE)
|
||||||
|
items = []
|
||||||
response = table.scan()
|
response = table.scan()
|
||||||
items = response.get("Items", [])
|
items.extend(response.get("Items", []))
|
||||||
# Sort by updated_at descending
|
while "LastEvaluatedKey" in response:
|
||||||
|
response = table.scan(ExclusiveStartKey=response["LastEvaluatedKey"])
|
||||||
|
items.extend(response.get("Items", []))
|
||||||
items.sort(key=lambda x: x.get("updated_at", ""), reverse=True)
|
items.sort(key=lambda x: x.get("updated_at", ""), reverse=True)
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue