def get(self): util.EnableCors(self) total = (TotalHandler.PRE_SHARDING_TOTAL + TotalHandler.WP_PLEDGE_TOTAL + TotalHandler.DEMOCRACY_DOT_COM_BALANCE + TotalHandler.CHECKS_BALANCE) total += model.ShardedCounter.get_count('TOTAL-5') result = dict(totalCents=total) team = self.request.get("team") if team: team_pledges = cache.GetTeamPledgeCount(team) or 0 team_total = cache.GetTeamTotal(team) or 0 try: # there are some memcache values with string values team_total = int(team_total) except ValueError, e: logging.exception("non-integral team total: %r", team_total) team_total = 0 if not (team_pledges and team_total): for pledge in model.Pledge.all().filter("team =", team): team_pledges += 1 team_total += pledge.amountCents # There was a pledge made to this team that was not made through Stripe if team == 'ahJzfm1heWRheS1wYWMtdGVhbXNyEQsSBFRlYW0YgICAgP7esAgM': team_pledges += 1 team_total += 1000000 cache.SetTeamPledgeCount(team, team_pledges) cache.SetTeamTotal(team, team_total) result['team'] = team result['teamPledges'] = team_pledges result['teamTotalCents'] = team_total
def run(self): for tt in model.TeamTotal.all(): team_pledges = cache.GetTeamPledgeCount(tt.team) or 0 if team_pledges != tt.num_pledges: tt.num_pledges = team_pledges tt.put()