master
Marek Baczynski 7 years ago
parent 9c69460261
commit c60fbfc67c

@ -164,6 +164,9 @@ def index():
if meal.accounted == 'no': if meal.accounted == 'no':
cook = {} cook = {}
if meal.kuk == '': #no kuk confirmed if meal.kuk == '': #no kuk confirmed
if len(meal.eaters) == 0:
cook['name'] = 'question'
else:
leaderboard = [] leaderboard = []
for eater in meal.eaters: for eater in meal.eaters:
candidate = {} candidate = {}
@ -171,12 +174,26 @@ def index():
candidate['score'] = Person.get(eater).kukPoints candidate['score'] = Person.get(eater).kukPoints
leaderboard.append(candidate) leaderboard.append(candidate)
leaderboard.sort(key=lambda tup : tup['score'], reverse = True) leaderboard.sort(key=lambda tup : tup['score'], reverse = True)
leaders = [p for p in leaderboard if p['score'] == leaderboard[0]['score']] leaders = [p['name'] for p in leaderboard if p['score'] == leaderboard[0]['score']]
if len(leaders) > 1: if len(leaders) > 1:
print "tie breaking!" print "tie breaking!"
cook['name'] = leaders[0]['name'] mid = Meal.getCurrent().mid-1
while len(leaders)>1:
thatkuk = mealHistory[mid].kuk
print "meal " + str(mid)
print thatkuk + " cooked that time"
if thatkuk in leaders:
print "found one!"
leaders.remove(thatkuk)
if mid == 0:
leaders.sort(key=lambda tup : tup['name'])
print "beaking!"
break
print str(len(leaders)) + " remaining"
mid-=1
cook['name'] = leaders[0]
else: else:
cook['name'] = leaders[0]['name'] cook['name'] = leaders[0]
cook['confirmed'] = 'no' cook['confirmed'] = 'no'
else: else:
cook['name'] = meal.kuk cook['name'] = meal.kuk

Loading…
Cancel
Save