Skip to content

Instantly share code, notes, and snippets.

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:
@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
@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
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 = {}
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())
@fangeugene
fangeugene / 2018_frc_registration.csv
Created November 20, 2017 04:36
2018 FRC Team Event Registration by time
Event Key Team Key Date Time (UTC)
2018azpx frc698 2017-09-28 18:34:16.021150
2018azpx frc991 2017-09-28 18:34:16.021360
2018azpx frc1290 2017-09-28 18:34:16.021540
2018azpx frc1492 2017-09-28 18:34:16.021670
2018azpx frc1633 2017-09-28 18:34:16.021980
2018azpx frc2375 2017-09-28 18:34:16.022310
2018azpx frc2403 2017-09-28 18:34:16.105460
2018azpx frc2647 2017-09-28 18:34:16.106810
2018azpx frc2662 2017-09-28 18:34:16.108040
@fangeugene
fangeugene / 2017cmpmo_f1m2_timeseries.csv
Last active February 4, 2018 07:55
Time series score from TBA-GDCV
Time Mode Red Score Blue Score Red Fuel Blue Fuel Red Rotors Blue Rotors Red Touchpads Blue Touchpads
0 pre_match 0 0 0 + 0/9 0 + 0/9 0 0 0 0
14 auto 0 0 0 + 0/9 0 + 0/9 0 0 0 0
13 auto 0 0 0 + 0/9 0 + 0/9 0 0 0 0
12 auto 0 15 0 + 0/9 0 + 0/9 0 0 0 0
11 auto 15 15 0 + 0/9 0 + 0/9 0 0 0 0
10 auto 15 15 0 + 0/9 0 + 0/9 0 0 0 0
9 auto 15 15 0 + 0/9 0 + 0/9 0 0 0 0
8 auto 16 15 1 + 0/9 0 + 0/9 0 0 0 0
7 auto 21 15 6 + 0/9 0 + 0/9 0 0 0 0
@fangeugene
fangeugene / f1m1.csv
Created February 19, 2018 00:32
2017week0 Time Series Scores
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 31 columns, instead of 22. in line 4.
time,matchKey,matchName,mode,timeRemaining,redScore,redForceCount,redForcePlayed,redLevitateCount,redLevitatePlayed,redBoostCount,redBoostPlayed,redScaleOwned,redSwitchOwned,redCurrentPowerup,redPowerupTimeRemaining,redAutoQuest,redFaceTheBoss,blueScore,blueForceCount,blueForcePlayed,blueLevitateCount,blueLevitatePlayed,blueBoostCount,blueBoostPlayed,blueScaleOwned,blueSwitchOwned,blueCurrentPowerup,bluePowerupTimeRemaining,blueAutoQuest,blueFaceTheBoss
2018-02-17 15:57:54.621448,f1m1,Final 1,auto,14,0,0,False,0,False,0,False,False,False,,,False,False,0,0,False,0,False,0,False,False,False,,,False,False
2018-02-17 15:57:55.621448,f1m1,Final 1,auto,13,0,0,False,0,False,0,False,False,False,,,False,False,0,0,False,0,False,0,False,False,False,,,False,False
2018-02-17 15:57:56.621448,f1m1,Final 1,auto,12,5,0,False,0,False,0,False,False,False,,,False,False,0,0,False,0,False,0,False,False,False,,,False,False
2018-02-17 15:57:57.621448,f1m1,Final 1,auto,11,5,0,False,0,False,0,False,False,False,,,False,False,0,0,False,
@fangeugene
fangeugene / gist:122278a305b617db884b209485217a6b
Last active April 8, 2018 19:43
Script to accept Team Media suggestions
from consts.account_permissions import AccountPermissions
from consts.media_type import MediaType
from controllers.suggestions.suggestions_review_base_controller import SuggestionsReviewBaseController
from google.appengine.ext import ndb
import json
from models.media import Media
from models.suggestion import Suggestion
from helpers.suggestions.media_creator import MediaCreator
from helpers.media_manipulator import MediaManipulator
from helpers.user_bundle import UserBundle
@fangeugene
fangeugene / 2018cmptx_pits.json
Created April 15, 2018 02:43
2018cmptx Pit Locations
{"locations": {"frc16": {"loc": "A33", "div": "Carver"}, "frc59": {"loc": "I41", "div": "Hopper"}, "frc100": {"loc": "B34", "div": "Carver"}, "frc108": {"loc": "C29", "div": "Carver"}, "frc118": {"loc": "B04", "div": "Newton"}, "frc120": {"loc": "G16", "div": "Turing"}, "frc148": {"loc": "H40", "div": "Hopper"}, "frc175": {"loc": "D37", "div": "Carver"}, "frc179": {"loc": "E01", "div": "Roebling"}, "frc180": {"loc": "H34", "div": "Hopper"}, "frc254": {"loc": "H33", "div": "Hopper"}, "frc294": {"loc": "H37", "div": "Hopper"}, "frc330": {"loc": "E37", "div": "Galileo"}, "frc341": {"loc": "C32", "div": "Carver"}, "frc342": {"loc": "A32", "div": "Carver"}, "frc343": {"loc": "C36", "div": "Carver"}, "frc359": {"loc": "H38", "div": "Hopper"}, "frc360": {"loc": "H02", "div": "Turing"}, "frc364": {"loc": "G09", "div": "Turing"}, "frc368": {"loc": "E38", "div": "Galileo"}, "frc399": {"loc": "G34", "div": "Hopper"}, "frc418": {"loc": "A37", "div": "Carver"}, "frc456": {"loc": "H25", "div": "Hopper"}, "frc488": {"loc":