Play nice with non-float allocations
authorSverre Rabbelier <srabbelier@gmail.com>
Sun, 08 Mar 2009 15:00:08 +0000
changeset 1748 f789ffe213a3
parent 1747 02f15a955c42
child 1749 a0ae6e6431a9
Play nice with non-float allocations Patch by: Sverre Rabbelier
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))