Skip to content

Instantly share code, notes, and snippets.

from consts.event_type import EventType
from database.team_query import EventTeamsQuery
from database.event_query import TeamYearEventsQuery
teams = EventTeamsQuery('2017hop').fetch()
team_events_futures = []
for team in teams:
team_events_futures.append(TeamYearEventsQuery(team.key.id(), 2017).fetch_async())
import datetime
from models.event import Event
events = Event.query().filter(
Event.start_date >= datetime.datetime(2017, 3, 29)).filter(
Event.start_date <= datetime.datetime(2017, 4, 2)).order(
Event.start_date).fetch()
gear_stats = {}
pressure_stats = {}
@fangeugene
fangeugene / gist:963495d725978a1fc8d7362c08c20058
Created April 3, 2017 01:10
Lists team component OPRs that feeds predictions
from helpers.event_helper import EventHelper
events = EventHelper.getWeekEvents()
gear_stats = {}
for event in events:
predictions = event.details.predictions
if predictions and predictions.get('stat_mean_vars'):
for team, val in predictions['stat_mean_vars']['qual']['gears']['mean'].items():
gear_stats[team] = val
@fangeugene
fangeugene / gist:0581ceec1eb88f629b13f5d3f1700bd8
Created March 13, 2017 18:39
Count Top Team Subscriptions
from models.subscription import Subscription
from collections import defaultdict
counts = defaultdict(int)
for s in Subscription.query(Subscription.model_type==1).fetch():
counts[s.model_key] += 1
sorted_counts = sorted(counts.items(), key=lambda x: -x[1])
for team, count in sorted_counts[:100]:
print team, count
from models.match import Match
matches = Match.query(Match.year==2017).fetch()
near_count = 0
middle_count = 0
far_count = 0
for match in matches:
for color in ['red', 'blue']:
if not match.score_breakdown: