Skip to content

Commit c927b18

Browse files
committed
clean up codebase a bit
1 parent e748f19 commit c927b18

File tree

11 files changed

+271
-1136
lines changed

11 files changed

+271
-1136
lines changed

assets/html/admin/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115

116116
<h1 style="text-align: center;">Dashboard</h1>
117117

118-
<div style="display: flex; flex-direction: row; gap: 10px;">
118+
<div style="display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; margin-left: 1rem; margin-right: 1rem;">
119119
<button onclick="recalculate_ratings()" class="button">Recalculate Ratings</button>
120120
<button onclick="recalculate_sm5_ratings()" class="button">Recalculate SM5 Ratings</button>
121121
<button onclick="recalculate_laserball_ratings()" class="button">Recalculate Laserball Ratings</button>
@@ -126,7 +126,7 @@ <h1 style="text-align: center;">Dashboard</h1>
126126

127127
<!-- Banner -->
128128

129-
<div style="display: flex; flex-direction: row; gap: 10px; margin-top: 5rem;">
129+
<div style="display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; margin-top: 5rem; margin-left: 1rem; margin-right: 1rem;">
130130
<input type="text" id="banner_text" placeholder="Banner Text" id="banner_text">
131131
<select id="banner_type" id="banner_type">
132132
<option value="info">Info</option>

config.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import json
22
import sys
33
import os
4+
from db.config import get_tortoise_orm_config
5+
6+
def is_in_ipython() -> bool:
7+
try:
8+
__IPYTHON__
9+
return True
10+
except NameError:
11+
return False
412

513
path = os.path.dirname(os.path.realpath(__file__))
614

@@ -17,7 +25,6 @@
1725

1826
config_options = list(default_config.keys())
1927

20-
2128
class JsonFile:
2229
def __init__(self, file_name: str) -> None:
2330
self.file = None
@@ -59,5 +66,8 @@ def write_file(self, new_content: dict) -> None:
5966
jconfig.write_file(config)
6067
print("Your config has been updated! Please change the new vaulues to your liking.")
6168

62-
if "pytest" not in sys.modules:
69+
70+
if "pytest" not in sys.modules and not is_in_ipython():
6371
raise SystemExit
72+
73+
TORTOISE_ORM = get_tortoise_orm_config(config)

db/config.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def get_tortoise_orm_config(config_obj):
2+
return {
3+
"connections": {
4+
"default": f"mysql://{config_obj['db_user']}:{config_obj['db_password']}@{config_obj['db_host']}:{config_obj['db_port']}/{config_obj['db_name']}",
5+
},
6+
"apps": {
7+
"models": {
8+
"models": ["db.game", "db.laserball", "db.legacy", "db.player", "db.sm5", "db.tag", "aerich.models"],
9+
"default_connection": "default"
10+
}
11+
}
12+
}

helpers/statshelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ async def get_ranking_accuracy() -> float:
681681
red_score, green_score = await game.get_team_score(Team.RED), await game.get_team_score(Team.GREEN)
682682

683683
# see if scores are close enough
684-
if int(red_chance) == int(green_chance) and abs(red_score - green_score) <= 3000:
684+
if abs(red_chance - green_chance) <= 0.08 and abs(red_score - green_score) <= 3000:
685685
# if so, add 2 to correct
686686
# it means we did a phoenomenal job at predicting the winner
687687
# technically this means our rating could be higher than 100%

helpers/tdfhelper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ async def parse_laserball_game(file_location: str) -> LaserballGame:
793793
team1_len = await game.entity_ends.filter(entity__team=team1, entity__type="player").count()
794794
team2_len = await game.entity_ends.filter(entity__team=team2, entity__type="player").count()
795795

796-
# 1 < team size
796+
# team size < 1
797797

798798
if team1_len < 1 or team2_len < 1:
799799
ranked = False

stats/elo_race.ipynb

Lines changed: 0 additions & 196 deletions
This file was deleted.

0 commit comments

Comments
 (0)