# HG changeset patch # User Sverre Rabbelier # Date 1236524408 0 # Node ID f789ffe213a3cf0d6bb3c8ed3db7ef2946f70fb6 # Parent 02f15a955c42ade9cf29e75a7f80ffe1fed2d896 Play nice with non-float allocations Patch by: Sverre Rabbelier diff -r 02f15a955c42 -r f789ffe213a3 app/soc/logic/allocations.py --- a/app/soc/logic/allocations.py Sun Mar 08 14:38:24 2009 +0000 +++ b/app/soc/logic/allocations.py Sun Mar 08 15:00:08 2009 +0000 @@ -181,8 +181,8 @@ if org in locked_orgs: slots = locked_slots[org] - else: - weight = float(org_applications_count) / unallocated_applications_count + elif unallocated_applications_count: + weight = float(org_applications_count) / float(unallocated_applications_count) slots = int(math.floor(weight*available_slots)) if org in adjusted_orgs: @@ -226,7 +226,7 @@ # adjust the orgs in need of adjusting for org in adjusted_orgs: - slots = adjusted_slots[org] + slots = float(adjusted_slots[org]) adjustment = (float(total_popularity)/float(available_slots))*slots adjustment = int(math.ceil(adjustment))