mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-27 09:59:10 +00:00
Add files via upload
This commit is contained in:
parent
251ba0b665
commit
2d6dbc037c
60
data analysis/scoutflex2019.py
Normal file
60
data analysis/scoutflex2019.py
Normal file
@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Wed Mar 20 12:21:31 2019
|
||||
|
||||
@author: creek
|
||||
"""
|
||||
|
||||
from google.cloud import firestore
|
||||
from google.oauth2 import service_account
|
||||
import pprint
|
||||
from pylatex import Document, Section, Subsection, Command
|
||||
from pylatex.utils import italic, NoEscape
|
||||
import requests
|
||||
|
||||
def generate_team_report(team):
|
||||
doc = Document('basic')
|
||||
matches = team.reference.collection(u'matches').get()
|
||||
matchnums = []
|
||||
for match in matches:
|
||||
matchnums.append(match.id)
|
||||
with doc.create(Section('Qualification matches scouted')):
|
||||
for matchnum in matchnums:
|
||||
doc.append(str(matchnum))
|
||||
with doc.create(Section('Details')):
|
||||
hab = "Hab 1"
|
||||
balls = 42
|
||||
hatches = 0
|
||||
count = 0
|
||||
for match in matches:
|
||||
for analysis in match:
|
||||
if analysis.key().startswith('Quant'):
|
||||
balls = balls + analysis['cargoBalls']
|
||||
hatches = hatches + analysis['hatchPanels']
|
||||
count = count + 1
|
||||
if analysis.key().startswith('Qual'):
|
||||
strategy = analysis['StrategyType']
|
||||
strongObject = analysis['TeleopStrongObject']
|
||||
if count > 0:
|
||||
doc.append("Average balls: " + str(float(balls)/count))
|
||||
doc.append("Average hatches: " + str(float(hatches)/count))
|
||||
doc.append("Strategy Type: " + str(strategy))
|
||||
doc.append("Strongest object in teleop: " + str(strongObject))
|
||||
|
||||
|
||||
doc.preamble.append(Command('title', team.id))
|
||||
doc.preamble.append(Command('author', 'Generated by Team 2022'))
|
||||
doc.preamble.append(Command('date', NoEscape(r'\today')))
|
||||
doc.append(NoEscape(r'\maketitle'))
|
||||
|
||||
doc.generate_pdf(filepath="C://Users//creek//Documents//" + str(team.id), clean_tex=False)
|
||||
|
||||
credentials = service_account.Credentials.from_service_account_file('titanscoutauth.json')
|
||||
|
||||
db = firestore.Client(project="titanscoutandroid", credentials=credentials)
|
||||
teams_ref = db.collection(u'data').document(u'team-2022').collection(u'Central 2019')
|
||||
teams = teams_ref.get()
|
||||
|
||||
for team in teams:
|
||||
generate_team_report(team)
|
||||
|
Loading…
Reference in New Issue
Block a user