```python # Don't do this (loads everything at onc...
# general-english
j
Copy code
python
# Don't do this (loads everything at once):
all_calls = vapi_client.calls.list()  # Could be thousands of calls!

# Do this instead (process in batches):
limit = 100  # Process 100 calls at a time
while True:
    calls_batch = vapi_client.calls.list(limit=limit)
    if not calls_batch:  # No more calls to process
        break
        
    for call in calls_batch:
        cost_data = {
            'call_id': call.get('id'),
            'total': call.get('cost', 0),
            'breakdown': call.get('costBreakdown', {})
        }
        # Process each call's cost data immediately
        # instead of keeping everything in memory
2 Views