mirror of
https://github.com/titanscouting/tra-superscript.git
synced 2025-09-26 07:10:18 +00:00
Merge branch 'competition'
This commit is contained in:
129
src/data.py
129
src/data.py
@@ -1,129 +0,0 @@
|
||||
import requests
|
||||
import pymongo
|
||||
import pandas as pd
|
||||
import time
|
||||
|
||||
def pull_new_tba_matches(apikey, competition, cutoff):
|
||||
api_key= apikey
|
||||
x=requests.get("https://www.thebluealliance.com/api/v3/event/"+competition+"/matches/simple", headers={"X-TBA-Auth_Key":api_key})
|
||||
out = []
|
||||
for i in x.json():
|
||||
if i["actual_time"] != None and i["actual_time"]-cutoff >= 0 and i["comp_level"] == "qm":
|
||||
out.append({"match" : i['match_number'], "blue" : list(map(lambda x: int(x[3:]), i['alliances']['blue']['team_keys'])), "red" : list(map(lambda x: int(x[3:]), i['alliances']['red']['team_keys'])), "winner": i["winning_alliance"]})
|
||||
return out
|
||||
|
||||
def get_team_match_data(apikey, competition, team_num):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_scouting
|
||||
mdata = db.matchdata
|
||||
out = {}
|
||||
for i in mdata.find({"competition" : competition, "team_scouted": team_num}):
|
||||
out[i['match']] = i['data']
|
||||
return pd.DataFrame(out)
|
||||
|
||||
def get_team_pit_data(apikey, competition, team_num):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_scouting
|
||||
mdata = db.pitdata
|
||||
out = {}
|
||||
return mdata.find_one({"competition" : competition, "team_scouted": team_num})["data"]
|
||||
|
||||
def get_team_metrics_data(apikey, competition, team_num):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_processing
|
||||
mdata = db.team_metrics
|
||||
return mdata.find_one({"competition" : competition, "team": team_num})
|
||||
|
||||
def get_match_data_formatted(apikey, competition):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_scouting
|
||||
mdata = db.teamlist
|
||||
x=mdata.find_one({"competition":competition})
|
||||
out = {}
|
||||
for i in x:
|
||||
try:
|
||||
out[int(i)] = unkeyify_2l(get_team_match_data(apikey, competition, int(i)).transpose().to_dict())
|
||||
except:
|
||||
pass
|
||||
return out
|
||||
|
||||
def get_metrics_data_formatted(apikey, competition):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_scouting
|
||||
mdata = db.teamlist
|
||||
x=mdata.find_one({"competition":competition})
|
||||
out = {}
|
||||
for i in x:
|
||||
try:
|
||||
out[int(i)] = d.get_team_metrics_data(apikey, competition, int(i))
|
||||
except:
|
||||
pass
|
||||
return out
|
||||
|
||||
def get_pit_data_formatted(apikey, competition):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_scouting
|
||||
mdata = db.teamlist
|
||||
x=mdata.find_one({"competition":competition})
|
||||
out = {}
|
||||
for i in x:
|
||||
try:
|
||||
out[int(i)] = get_team_pit_data(apikey, competition, int(i))
|
||||
except:
|
||||
pass
|
||||
return out
|
||||
|
||||
def get_pit_variable_data(apikey, competition):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_processing
|
||||
mdata = db.team_pit
|
||||
out = {}
|
||||
return mdata.find()
|
||||
|
||||
def get_pit_variable_formatted(apikey, competition):
|
||||
temp = get_pit_variable_data(apikey, competition)
|
||||
out = {}
|
||||
for i in temp:
|
||||
out[i["variable"]] = i["data"]
|
||||
return out
|
||||
|
||||
def push_team_tests_data(apikey, competition, team_num, data, dbname = "data_processing", colname = "team_tests"):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client[dbname]
|
||||
mdata = db[colname]
|
||||
mdata.replace_one({"competition" : competition, "team": team_num}, {"_id": competition+str(team_num)+"am", "competition" : competition, "team" : team_num, "data" : data}, True)
|
||||
|
||||
def push_team_metrics_data(apikey, competition, team_num, data, dbname = "data_processing", colname = "team_metrics"):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client[dbname]
|
||||
mdata = db[colname]
|
||||
mdata.replace_one({"competition" : competition, "team": team_num}, {"_id": competition+str(team_num)+"am", "competition" : competition, "team" : team_num, "metrics" : data}, True)
|
||||
|
||||
def push_team_pit_data(apikey, competition, variable, data, dbname = "data_processing", colname = "team_pit"):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client[dbname]
|
||||
mdata = db[colname]
|
||||
mdata.replace_one({"competition" : competition, "variable": variable}, {"competition" : competition, "variable" : variable, "data" : data}, True)
|
||||
|
||||
def get_analysis_flags(apikey, flag):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_processing
|
||||
mdata = db.flags
|
||||
return mdata.find_one({flag:{"$exists":True}})
|
||||
|
||||
def set_analysis_flags(apikey, flag, data):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_processing
|
||||
mdata = db.flags
|
||||
return mdata.replace_one({flag:{"$exists":True}}, data, True)
|
||||
|
||||
def unkeyify_2l(layered_dict):
|
||||
out = {}
|
||||
for i in layered_dict.keys():
|
||||
add = []
|
||||
sortkey = []
|
||||
for j in layered_dict[i].keys():
|
||||
add.append([j,layered_dict[i][j]])
|
||||
add.sort(key = lambda x: x[0])
|
||||
out[i] = list(map(lambda x: x[1], add))
|
||||
return out
|
151
src/design.kv
151
src/design.kv
@@ -1,151 +0,0 @@
|
||||
<Launch>:
|
||||
orientation: "vertical"
|
||||
|
||||
NavigationLayout:
|
||||
ScreenManager:
|
||||
id: screen_manager
|
||||
HomeScreen:
|
||||
name: "Home"
|
||||
BoxLayout:
|
||||
orientation: "vertical"
|
||||
MDToolbar:
|
||||
title: screen_manager.current
|
||||
elevation: 10
|
||||
left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]]
|
||||
|
||||
GridLayout:
|
||||
cols: 1
|
||||
padding: 15, 15
|
||||
spacing: 20, 20
|
||||
MDTextFieldRect:
|
||||
hint_text: "Console Log"
|
||||
# size_hint: .8, None
|
||||
# align: 'center'
|
||||
# Widget:
|
||||
SettingsScreen:
|
||||
name: "Settings"
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
MDToolbar:
|
||||
title: screen_manager.current
|
||||
elevation: 10
|
||||
left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]]
|
||||
Widget:
|
||||
InfoScreen:
|
||||
name: "Info"
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
MDToolbar:
|
||||
title: screen_manager.current
|
||||
elevation: 10
|
||||
left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]]
|
||||
# GridLayout:
|
||||
# cols: 2
|
||||
# padding: 15, 15
|
||||
# spacing: 20, 20
|
||||
BoxLayout:
|
||||
orientation: "horizontal"
|
||||
MDLabel:
|
||||
text: "DB Key:"
|
||||
halign: 'center'
|
||||
MDTextField:
|
||||
hint_text: "placeholder"
|
||||
pos_hint: {"center_y": .5}
|
||||
|
||||
BoxLayout:
|
||||
orientation: "horizontal"
|
||||
MDLabel:
|
||||
text: "TBA Key:"
|
||||
halign: 'center'
|
||||
MDTextField:
|
||||
hint_text: "placeholder"
|
||||
pos_hint: {"center_y": .5}
|
||||
BoxLayout:
|
||||
orientation: "horizontal"
|
||||
MDLabel:
|
||||
text: "CPU Use:"
|
||||
halign: 'center'
|
||||
MDLabel:
|
||||
text: "placeholder"
|
||||
halign: 'center'
|
||||
BoxLayout:
|
||||
orientation: "horizontal"
|
||||
MDLabel:
|
||||
text: "Network:"
|
||||
halign: 'center'
|
||||
MDLabel:
|
||||
text: "placeholder"
|
||||
halign: 'center'
|
||||
Widget:
|
||||
BoxLayout:
|
||||
orientation: "horizontal"
|
||||
MDLabel:
|
||||
text: "Progress"
|
||||
halign: 'center'
|
||||
MDProgressBar:
|
||||
id: progress
|
||||
value: 50
|
||||
StatsScreen:
|
||||
name: "Stats"
|
||||
MDCheckbox:
|
||||
size_hint: None, None
|
||||
size: "48dp", "48dp"
|
||||
pos_hint: {'center_x': .5, 'center_y': .5}
|
||||
on_active: Screen.test()
|
||||
|
||||
#Navigation Drawer -------------------------
|
||||
MDNavigationDrawer:
|
||||
id: nav_drawer
|
||||
BoxLayout:
|
||||
orientation: "vertical"
|
||||
padding: "8dp"
|
||||
spacing: "8dp"
|
||||
MDLabel:
|
||||
text: "Titan Scouting"
|
||||
font_style: "Button"
|
||||
size_hint_y: None
|
||||
height: self.texture_size[1]
|
||||
|
||||
MDLabel:
|
||||
text: "Data Analysis"
|
||||
font_style: "Caption"
|
||||
size_hint_y: None
|
||||
height: self.texture_size[1]
|
||||
ScrollView:
|
||||
MDList:
|
||||
OneLineAvatarListItem:
|
||||
text: "Home"
|
||||
on_press:
|
||||
# nav_drawer.set_state("close")
|
||||
# screen_manager.transition.direction = "left"
|
||||
screen_manager.current = "Home"
|
||||
IconLeftWidget:
|
||||
icon: "home"
|
||||
|
||||
OneLineAvatarListItem:
|
||||
text: "Settings"
|
||||
on_press:
|
||||
# nav_drawer.set_state("close")
|
||||
# screen_manager.transition.direction = "right"
|
||||
# screen_manager.fade
|
||||
screen_manager.current = "Settings"
|
||||
IconLeftWidget:
|
||||
icon: "cog"
|
||||
OneLineAvatarListItem:
|
||||
text: "Info"
|
||||
on_press:
|
||||
# nav_drawer.set_state("close")
|
||||
# screen_manager.transition.direction = "right"
|
||||
# screen_manager.fade
|
||||
screen_manager.current = "Info"
|
||||
IconLeftWidget:
|
||||
icon: "cog"
|
||||
OneLineAvatarListItem:
|
||||
text: "Stats"
|
||||
on_press:
|
||||
# nav_drawer.set_state("close")
|
||||
# screen_manager.transition.direction = "right"
|
||||
# screen_manager.fade
|
||||
screen_manager.current = "Stats"
|
||||
IconLeftWidget:
|
||||
icon: "cog"
|
58
src/main.py
58
src/main.py
@@ -1,58 +0,0 @@
|
||||
from kivy.lang import Builder
|
||||
|
||||
from kivymd.uix.screen import Screen
|
||||
from kivymd.uix.list import OneLineListItem, MDList, TwoLineListItem, ThreeLineListItem
|
||||
from kivymd.uix.list import OneLineIconListItem, IconLeftWidget
|
||||
from kivy.uix.scrollview import ScrollView
|
||||
|
||||
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.uix.screenmanager import ScreenManager, Screen
|
||||
from kivy.uix.dropdown import DropDown
|
||||
from kivy.uix.button import Button
|
||||
from kivy.base import runTouchApp
|
||||
from kivymd.uix.menu import MDDropdownMenu, MDMenuItem
|
||||
|
||||
from kivymd.app import MDApp
|
||||
# import superscript as ss
|
||||
|
||||
# from tra_analysis import analysis as an
|
||||
import data as d
|
||||
from collections import defaultdict
|
||||
import json
|
||||
import math
|
||||
import numpy as np
|
||||
import os
|
||||
from os import system, name
|
||||
from pathlib import Path
|
||||
from multiprocessing import Pool
|
||||
import matplotlib.pyplot as plt
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import time
|
||||
import warnings
|
||||
|
||||
# global exec_threads
|
||||
|
||||
|
||||
# Screens
|
||||
class HomeScreen(Screen):
|
||||
pass
|
||||
class SettingsScreen(Screen):
|
||||
pass
|
||||
class InfoScreen(Screen):
|
||||
pass
|
||||
|
||||
class StatsScreen(Screen):
|
||||
pass
|
||||
|
||||
|
||||
class MyApp(MDApp):
|
||||
def build(self):
|
||||
self.theme_cls.primary_palette = "Red"
|
||||
return Builder.load_file("design.kv")
|
||||
def test():
|
||||
print("test")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
MyApp().run()
|
Reference in New Issue
Block a user