summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/match_up/__init__.py3
-rw-r--r--src/match_up/controller.py4
-rw-r--r--src/match_up/routes.py7
-rw-r--r--src/match_up/utilities.py30
4 files changed, 1 insertions, 43 deletions
diff --git a/src/match_up/__init__.py b/src/match_up/__init__.py
index 25b4d73..e6c472a 100644
--- a/src/match_up/__init__.py
+++ b/src/match_up/__init__.py
@@ -2,7 +2,6 @@ from flask import Flask
from waitress import serve
from argparse import ArgumentParser
from importlib.resources import path
-from match_up.utilities import Timer
from match_up.controller import RoundGenerator
from match_up.model import CourtList, PlayerList
@@ -22,12 +21,10 @@ from match_up import routes
def main():
parser = ArgumentParser()
- parser.add_argument("-t", "--timer", help="Min per round", type=float, default=12)
parser.add_argument("-c", "--courts", help="Total courts", type=int, default=12)
parser.add_argument("-d", "--database", help="CSV database", default=None)
args = parser.parse_args()
global rg
rg.courts = CourtList(total=args.courts)
- rg.timer = Timer(max_mins=args.timer)
rg.players = PlayerList(csv_location=args.database)
serve(app, port=80)
diff --git a/src/match_up/controller.py b/src/match_up/controller.py
index 3b4a6f9..aa72b12 100644
--- a/src/match_up/controller.py
+++ b/src/match_up/controller.py
@@ -1,7 +1,7 @@
from typing import Tuple
from operator import attrgetter
from dataclasses import dataclass, field
-from match_up.utilities import sample_list, Timer
+from match_up.utilities import sample_list
from match_up.model import (
Team,
Game,
@@ -72,7 +72,6 @@ class RoundGenerator:
proposal: tuple = tuple()
def __post_init__(self) -> None:
- self.timer = Timer()
self.games = _create_placeholders(self.courts.get_courts(), "---")
def _separate_courts(self, courts: dict) -> Tuple[dict, dict]:
@@ -123,5 +122,4 @@ class RoundGenerator:
self.players.increment_game_count(identifiers)
self.proposal = tuple()
self.round += 1
- self.timer.start()
return self.games
diff --git a/src/match_up/routes.py b/src/match_up/routes.py
index 95abe9e..f64eafa 100644
--- a/src/match_up/routes.py
+++ b/src/match_up/routes.py
@@ -10,13 +10,6 @@ def home():
return re.get_template("index.j2").render(url_for=url_for)
-@app.route("/time", methods=["GET"])
-def get_time():
- mins, secs = rg.timer.get()
- t = re.from_string('{% from "macros.j2" import timer %}{{timer(mins, secs)}}')
- return render_template(t, mins=mins, secs=secs)
-
-
@app.route("/control", methods=["GET"])
def get_controls():
return render_template("controls.j2", courts=rg.courts.get_courts())
diff --git a/src/match_up/utilities.py b/src/match_up/utilities.py
index 8a905ba..8aadfd2 100644
--- a/src/match_up/utilities.py
+++ b/src/match_up/utilities.py
@@ -27,33 +27,3 @@ def sample_list(indices: list, cost: list[int], count: int = None) -> list:
indices, cost = _shuffle_two_lists(indices, cost)
indices = _pick_from_list_after_sorting_other(indices, cost)[:count]
return indices
-
-
-@dataclass
-class Timer:
- max_mins: float = DEFAULT_TIMER
- ref: float = None
- running: bool = False
- default: str = ("00", "00")
-
- def __post_init__(self):
- self.max_seconds = self.max_mins * SECS_IN_MIN
-
- def start(self):
- self.ref = time() + self.max_seconds
- self.running = True
-
- def stop(self):
- self.ref = None
- self.running = False
-
- def get(self):
- if not self.running:
- return self.default
- total_seconds = self.ref - time()
- if total_seconds < 0:
- self.stop()
- return self.default
- mins = f"{int(total_seconds // SECS_IN_MIN):02d}"
- secs = f"{int(total_seconds % SECS_IN_MIN):02d}"
- return mins, secs