From d3b39d816702a69efecbf06ff1f28d33e1e69d92 Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Thu, 21 Mar 2019 22:17:33 -0500 Subject: [PATCH 1/3] Delete test.py --- data analysis/test.py | 97 ------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 data analysis/test.py diff --git a/data analysis/test.py b/data analysis/test.py deleted file mode 100644 index 79e7ee46..00000000 --- a/data analysis/test.py +++ /dev/null @@ -1,97 +0,0 @@ -import firebase_admin -from firebase_admin import credentials -from firebase_admin import firestore -import csv -import numpy as np - -# Use a service account -cred = credentials.Certificate('keys/keytemp.json') -#add your own key as this is public. email me for details -firebase_admin.initialize_app(cred) - -db = firestore.client() - -teams=db.collection('data').document('team-2022').collection("Central 2019").get() -full=[] -tms=[] -for team in teams: - - tms.append(team.id) - reports=db.collection('data').document('team-2022').collection("Central 2019").document(team.id).collection("matches").get() - - for report in reports: - data=[] - data.append(db.collection('data').document('team-2022').collection("Central 2019").document(team.id).collection("matches").document(report.id).get().to_dict()) - full.append(data) - -quant_keys = [] - -list_teams = ["2022", "16", "2451"] - -out = [] -var = {} - -for i in range(len(full)): - for j in range(len(full[i])): - for key in list(full[i][j].keys()): - - if "Quantitative" in key: - - quant_keys.append(key) - - if full[i][j].get(key).get('teamDBRef')[5:] in list_teams: - - var = {} - measured_vars = [] - - for k in range(len(list(full[i][j].get(key).keys()))): - - individual_keys = list(full[i][j].get(key).keys()) - - var[individual_keys[k]] = full[i][j].get(key).get(individual_keys[k]) - - out.append(var) - -sorted_out = [] - -for i in out: - - j_list = [] - - key_list = [] - - sorted_keys = sorted(i.keys()) - - for j in sorted_keys: - - key_list.append(i[j]) - - j_list.append(j) - - sorted_out.append(key_list) - -var_index = 0 -team_index = 0 - -big_out = [] - -for j in range(len(i)): - big_out.append([]) - for t in range(len(list_teams)): - big_out[j].append([]) - -for i in sorted_out: - - team_index = list_teams.index(sorted_out[sorted_out.index(i)][j_list.index('teamDBRef')][5:]) - - for j in range(len(i)): - - big_out[j][team_index].append(i[j]) - -for i in range(len(big_out)): - - with open('data/' + j_list[i] + '.csv', "w+", newline = '') as file: - - writer = csv.writer(file, delimiter = ',') - writer.writerows(big_out[i]) - From 35d8e5ff77d528bf343292492e8f7c4cc7a0a6cc Mon Sep 17 00:00:00 2001 From: Archan Das Date: Thu, 21 Mar 2019 22:50:27 -0500 Subject: [PATCH 2/3] Add files via upload --- data analysis/scoutflex2019.py | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 data analysis/scoutflex2019.py diff --git a/data analysis/scoutflex2019.py b/data analysis/scoutflex2019.py new file mode 100644 index 00000000..d683eefe --- /dev/null +++ b/data analysis/scoutflex2019.py @@ -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) + From 040b4dc52adb0d4d24f2031fdf942f40744211be Mon Sep 17 00:00:00 2001 From: Archan Das Date: Thu, 21 Mar 2019 22:52:08 -0500 Subject: [PATCH 3/3] Add files via upload --- data analysis/scoutflex2019.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data analysis/scoutflex2019.py b/data analysis/scoutflex2019.py index d683eefe..607b76fc 100644 --- a/data analysis/scoutflex2019.py +++ b/data analysis/scoutflex2019.py @@ -49,7 +49,7 @@ def generate_team_report(team): doc.generate_pdf(filepath="C://Users//creek//Documents//" + str(team.id), clean_tex=False) -credentials = service_account.Credentials.from_service_account_file('titanscoutauth.json') +credentials = service_account.Credentials.from_service_account_file('keys/firebasekey.json') db = firestore.Client(project="titanscoutandroid", credentials=credentials) teams_ref = db.collection(u'data').document(u'team-2022').collection(u'Central 2019')