From f64af6d10127aee69026e80e6b65fc11f657c992 Mon Sep 17 00:00:00 2001 From: Jago Gardiner <jagogardiner@gmail.com> Date: Mon, 10 Apr 2023 15:34:47 +0100 Subject: [PATCH] Cleanup project, removing dependencies and fixing Python lint errors Change-Id: I2d18e347207b99566e6872712f67411ca4b72692 Signed-off-by: Jago Gardiner <jagogardiner@gmail.com> --- app/__init__.py | 1 - app/main.py | 2 +- data/__init__.py | 10 ---------- data/model.py | 27 --------------------------- data/player.py | 3 ++- data/teams.py | 5 ----- 6 files changed, 3 insertions(+), 45 deletions(-) delete mode 100644 data/__init__.py delete mode 100644 data/model.py diff --git a/app/__init__.py b/app/__init__.py index d73fa76..32394cb 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,6 +1,5 @@ # Flask init for the web app. from flask import Flask -from data import db from dotenv import load_dotenv from flask_assets import Environment, Bundle import os diff --git a/app/main.py b/app/main.py index ee2e97d..df33e15 100644 --- a/app/main.py +++ b/app/main.py @@ -9,4 +9,4 @@ app = Blueprint("app", __name__) # Import the routes # Avoid circular imports -from app import routes +from app import routes # noqa: F401, E402 diff --git a/data/__init__.py b/data/__init__.py deleted file mode 100644 index 0a9d467..0000000 --- a/data/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# db module init -from flask_sqlalchemy import SQLAlchemy - -db = SQLAlchemy() - -from .model import Player, Team, Results - -# init db -def init_db(): - db.create_all() diff --git a/data/model.py b/data/model.py deleted file mode 100644 index aed04a0..0000000 --- a/data/model.py +++ /dev/null @@ -1,27 +0,0 @@ -# db start -from . import db - - -class Player(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(80), unique=True, nullable=False) - dob = db.Column(db.Date, nullable=False) - gender = db.Column(db.String(10), nullable=False) - date_signed = db.Column(db.Date, nullable=False) - contract_start = db.Column(db.Date, nullable=False) - contract_duration = db.Column(db.Integer, nullable=False) # in weeks - team_id = db.Column(db.Integer, db.ForeignKey("team.id"), nullable=False) - - -class Team(db.Model): - id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(80), unique=True, nullable=False) - location = db.Column(db.String(80), nullable=False) - manager = db.Column(db.String(80), nullable=False) - - -class Results(db.Model): - id = db.Column(db.Integer, primary_key=True) - game_week = db.Column(db.Integer, nullable=False) - player_id = db.Column(db.Integer, db.ForeignKey("player.id"), nullable=False) - result = db.Column(db.Integer, nullable=False) # 0 = loss/draw, 1 = win diff --git a/data/player.py b/data/player.py index 34d6699..845ff6d 100644 --- a/data/player.py +++ b/data/player.py @@ -43,7 +43,8 @@ def calculate_win_percentage_last_5(player: Player) -> dict: player (Player): Player object Returns: - dict: Win percentage per the last 5 games and the affect on the overall win percentage + dict: Win percentage per the last 5 games and the affect on the + overall win percentage. """ result_percentage = {} games_won = player.games_won diff --git a/data/teams.py b/data/teams.py index 3413b96..7f3cc1c 100644 --- a/data/teams.py +++ b/data/teams.py @@ -1,18 +1,13 @@ from .processing import ( - Player, - Team, get_objects, read_csv, filter_players, - filter_teams, ) from .player import ( calculate_win_percentage_overall, calculate_win_percentage_last_5, calculate_win_percentage_base, - transfer_value_overall, transfer_value_last_5, - transfer_value_base, ) -- GitLab