Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created June 4, 2013 19:45
Show Gist options
  • Save qpfiffer/5708910 to your computer and use it in GitHub Desktop.
Save qpfiffer/5708910 to your computer and use it in GitHub Desktop.
Functional fun!
rt = Factory.route_trip()
drops = rt.droppoint_set.all()
managers = [drop.droppointmembership_set.filter(is_drop_manager=True)
for drop in drops]
# flatten the list of managers:
managers = [manager for manager_list in managers for manager in manager_list]
credits = [manager.customer.credits.count() for manager in managers]
credits = reduce(lambda x, y: x + y, credits, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment