Permalink
Browse files

Add a script that re-calculates all the league scores.

This can be run at any time, as it clears the values before it runs.
  • Loading branch information...
1 parent 4b4fdc5 commit d90e9d6c91ede20cc3f3ec9098f7adb364e99c79 @PeterJCLaw committed Apr 15, 2012
Showing with 44 additions and 0 deletions.
  1. +44 −0 bin/league-score
View
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+"""
+Calculates the current league points & stores them.
+Can be run at any point, as it clears them first.
+"""
+
+import redis
+
+import scores
+
+
+HOST = "localhost"
+PORT = 6379
+DB = 0
+
+BASE = 'org.srobo'
+
+actor = redis.Redis(host=HOST, port=PORT, db=DB)
+
+# Remove the old data
+
+teams = actor.keys(BASE + '.scores.team.*')
+#print teams
+for t in teams:
+ actor.delete(t)
+
+matchKeys = actor.keys(BASE + '.scores.match.*')
+#print matchKeys
+
+matches = set()
+
+for key in matchKeys:
+ # Store that this match exists
+ m = key.split('.')[-2]
+ matches.add(m)
+ actor.hset(key, 'league_points', 0.0)
+
+#print matches
+
+# Figure out the new data
+
+for m in matches:
+ scores.match_rank(m, False)

0 comments on commit d90e9d6

Please sign in to comment.