expand database schema and add blueprints for Tournament feature
This commit is contained in:
parent
3eb9d6ab8c
commit
1679f537de
@ -1,15 +1,15 @@
|
|||||||
CREATE DATABASE IF NOT EXISTS `ez_lan_manager` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
|
CREATE DATABASE IF NOT EXISTS `ez_lan_manager` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
|
||||||
USE `ez_lan_manager`;
|
USE `ez_lan_manager`;
|
||||||
-- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64)
|
-- MySQL dump 10.13 Distrib 8.0.41, for Win64 (x86_64)
|
||||||
--
|
--
|
||||||
-- Host: 127.0.0.1 Database: ez_lan_manager
|
-- Host: 127.0.0.1 Database: ez_lan_manager
|
||||||
-- ------------------------------------------------------
|
-- ------------------------------------------------------
|
||||||
-- Server version 5.5.5-10.11.8-MariaDB-0ubuntu0.24.04.1
|
-- Server version 5.5.5-10.4.32-MariaDB
|
||||||
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
/*!40101 SET NAMES utf8 */;
|
/*!50503 SET NAMES utf8 */;
|
||||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||||
@ -23,7 +23,7 @@ USE `ez_lan_manager`;
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `catering_menu_items`;
|
DROP TABLE IF EXISTS `catering_menu_items`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `catering_menu_items` (
|
CREATE TABLE `catering_menu_items` (
|
||||||
`catering_menu_item_id` int(11) NOT NULL AUTO_INCREMENT,
|
`catering_menu_item_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`name` varchar(45) NOT NULL,
|
`name` varchar(45) NOT NULL,
|
||||||
@ -32,7 +32,7 @@ CREATE TABLE `catering_menu_items` (
|
|||||||
`category` varchar(80) NOT NULL,
|
`category` varchar(80) NOT NULL,
|
||||||
`is_disabled` tinyint(4) DEFAULT 0,
|
`is_disabled` tinyint(4) DEFAULT 0,
|
||||||
PRIMARY KEY (`catering_menu_item_id`)
|
PRIMARY KEY (`catering_menu_item_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -41,7 +41,7 @@ CREATE TABLE `catering_menu_items` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `news`;
|
DROP TABLE IF EXISTS `news`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `news` (
|
CREATE TABLE `news` (
|
||||||
`news_id` int(11) NOT NULL AUTO_INCREMENT,
|
`news_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`news_content` text DEFAULT NULL,
|
`news_content` text DEFAULT NULL,
|
||||||
@ -52,7 +52,7 @@ CREATE TABLE `news` (
|
|||||||
PRIMARY KEY (`news_id`),
|
PRIMARY KEY (`news_id`),
|
||||||
KEY `user_is_idx` (`news_author`),
|
KEY `user_is_idx` (`news_author`),
|
||||||
CONSTRAINT `user_is` FOREIGN KEY (`news_author`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
CONSTRAINT `user_is` FOREIGN KEY (`news_author`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -61,7 +61,7 @@ CREATE TABLE `news` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `order_catering_menu_item`;
|
DROP TABLE IF EXISTS `order_catering_menu_item`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `order_catering_menu_item` (
|
CREATE TABLE `order_catering_menu_item` (
|
||||||
`order_id` int(11) NOT NULL,
|
`order_id` int(11) NOT NULL,
|
||||||
`catering_menu_item_id` int(11) NOT NULL,
|
`catering_menu_item_id` int(11) NOT NULL,
|
||||||
@ -79,7 +79,7 @@ CREATE TABLE `order_catering_menu_item` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `orders`;
|
DROP TABLE IF EXISTS `orders`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `orders` (
|
CREATE TABLE `orders` (
|
||||||
`order_id` int(11) NOT NULL AUTO_INCREMENT,
|
`order_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`status` varchar(45) NOT NULL,
|
`status` varchar(45) NOT NULL,
|
||||||
@ -87,7 +87,7 @@ CREATE TABLE `orders` (
|
|||||||
`order_date` datetime NOT NULL DEFAULT current_timestamp(),
|
`order_date` datetime NOT NULL DEFAULT current_timestamp(),
|
||||||
`is_delivery` tinyint(4) NOT NULL DEFAULT 1,
|
`is_delivery` tinyint(4) NOT NULL DEFAULT 1,
|
||||||
PRIMARY KEY (`order_id`)
|
PRIMARY KEY (`order_id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -96,7 +96,7 @@ CREATE TABLE `orders` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `seats`;
|
DROP TABLE IF EXISTS `seats`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `seats` (
|
CREATE TABLE `seats` (
|
||||||
`seat_id` varchar(5) NOT NULL,
|
`seat_id` varchar(5) NOT NULL,
|
||||||
`is_blocked` tinyint(4) NOT NULL DEFAULT 0,
|
`is_blocked` tinyint(4) NOT NULL DEFAULT 0,
|
||||||
@ -113,7 +113,7 @@ CREATE TABLE `seats` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `tickets`;
|
DROP TABLE IF EXISTS `tickets`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `tickets` (
|
CREATE TABLE `tickets` (
|
||||||
`ticket_id` int(11) NOT NULL AUTO_INCREMENT,
|
`ticket_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`ticket_category` varchar(45) NOT NULL,
|
`ticket_category` varchar(45) NOT NULL,
|
||||||
@ -122,7 +122,40 @@ CREATE TABLE `tickets` (
|
|||||||
PRIMARY KEY (`ticket_id`),
|
PRIMARY KEY (`ticket_id`),
|
||||||
KEY `user_id_idx` (`user`),
|
KEY `user_id_idx` (`user`),
|
||||||
CONSTRAINT `user` FOREIGN KEY (`user`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
CONSTRAINT `user` FOREIGN KEY (`user`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `tournament_participants`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `tournament_participants`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
|
CREATE TABLE `tournament_participants` (
|
||||||
|
`tournament_id` int(11) NOT NULL,
|
||||||
|
`user_id` int(11) NOT NULL,
|
||||||
|
`registered_at_timestamp` varchar(45) NOT NULL DEFAULT 'CURRENT_TIMESTAMP',
|
||||||
|
PRIMARY KEY (`tournament_id`,`user_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `tournaments`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `tournaments`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
|
CREATE TABLE `tournaments` (
|
||||||
|
`tournament_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`name` varchar(45) NOT NULL,
|
||||||
|
`additional_info` varchar(300) DEFAULT NULL,
|
||||||
|
`start_time` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||||
|
`participants_limit` int(4) DEFAULT NULL,
|
||||||
|
`created_at` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
PRIMARY KEY (`tournament_id`,`start_time`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -131,7 +164,7 @@ CREATE TABLE `tickets` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `transactions`;
|
DROP TABLE IF EXISTS `transactions`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `transactions` (
|
CREATE TABLE `transactions` (
|
||||||
`transaction_id` int(11) NOT NULL AUTO_INCREMENT,
|
`transaction_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`user_id` int(11) NOT NULL,
|
`user_id` int(11) NOT NULL,
|
||||||
@ -143,7 +176,7 @@ CREATE TABLE `transactions` (
|
|||||||
UNIQUE KEY `transaction_id_UNIQUE` (`transaction_id`),
|
UNIQUE KEY `transaction_id_UNIQUE` (`transaction_id`),
|
||||||
KEY `user_id_idx` (`user_id`),
|
KEY `user_id_idx` (`user_id`),
|
||||||
CONSTRAINT `user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
CONSTRAINT `user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -152,7 +185,7 @@ CREATE TABLE `transactions` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `user_profile_picture`;
|
DROP TABLE IF EXISTS `user_profile_picture`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `user_profile_picture` (
|
CREATE TABLE `user_profile_picture` (
|
||||||
`user_id` int(11) NOT NULL,
|
`user_id` int(11) NOT NULL,
|
||||||
`picture` mediumblob DEFAULT NULL,
|
`picture` mediumblob DEFAULT NULL,
|
||||||
@ -167,7 +200,7 @@ CREATE TABLE `user_profile_picture` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `users`;
|
DROP TABLE IF EXISTS `users`;
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
/*!50503 SET character_set_client = utf8mb4 */;
|
||||||
CREATE TABLE `users` (
|
CREATE TABLE `users` (
|
||||||
`user_id` int(11) NOT NULL AUTO_INCREMENT,
|
`user_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`user_name` varchar(50) NOT NULL,
|
`user_name` varchar(50) NOT NULL,
|
||||||
@ -185,7 +218,7 @@ CREATE TABLE `users` (
|
|||||||
UNIQUE KEY `user_id_UNIQUE` (`user_id`),
|
UNIQUE KEY `user_id_UNIQUE` (`user_id`),
|
||||||
UNIQUE KEY `user_mail_UNIQUE` (`user_mail`),
|
UNIQUE KEY `user_mail_UNIQUE` (`user_mail`),
|
||||||
UNIQUE KEY `user_name_UNIQUE` (`user_name`)
|
UNIQUE KEY `user_name_UNIQUE` (`user_name`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||||
|
|
||||||
@ -197,4 +230,4 @@ CREATE TABLE `users` (
|
|||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||||
|
|
||||||
-- Dump completed on 2024-08-25 22:37:14
|
-- Dump completed on 2025-02-09 21:52:04
|
||||||
|
|||||||
@ -788,3 +788,21 @@ class DatabaseService:
|
|||||||
return await self.remove_profile_picture(user_id)
|
return await self.remove_profile_picture(user_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Error deleting user profile picture: {e}")
|
logger.warning(f"Error deleting user profile picture: {e}")
|
||||||
|
|
||||||
|
async def get_all_tournaments(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def get_tournament(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def get_all_registered_users_for_tournament(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def set_tournament_info(self, tournament_id, tournament_info):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def register_to_tournament(self, tournament_id, user_id):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def unregister_to_tournament(self, tournament_id, user_id):
|
||||||
|
pass
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from src.ez_lan_manager.services.DatabaseService import DatabaseService
|
||||||
|
from src.ez_lan_manager.types.Tournament import Tournament
|
||||||
|
from src.ez_lan_manager.types.User import User
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
|
|
||||||
|
class AlreadyRegisteredToTournamentError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TournamentService:
|
||||||
|
def __init__(self, db_service: DatabaseService):
|
||||||
|
self._db_service = db_service
|
||||||
|
|
||||||
|
async def get_all_tournaments(self) -> list[Tournament]:
|
||||||
|
return await self._db_service.get_all_tournaments()
|
||||||
|
|
||||||
|
async def get_tournament(self, tournament_id: int) -> Tournament:
|
||||||
|
return await self._db_service.get_tournament()
|
||||||
|
|
||||||
|
async def get_all_registered_users_for_tournament(self, tournament_id: int) -> list[User]:
|
||||||
|
return await self._db_service.get_all_registered_users_for_tournament(tournament_id)
|
||||||
|
|
||||||
|
async def register_to_tournament(self, tournament_id: int, user_id: int) -> None:
|
||||||
|
await self._db_service.register_to_tournament(tournament_id, user_id)
|
||||||
|
|
||||||
|
async def unregister_to_tournament(self, tournament_id: int, user_id: int) -> None:
|
||||||
|
await self._db_service.unregister_to_tournament(tournament_id, user_id)
|
||||||
|
|
||||||
|
async def set_tournament_info(self, tournament_id: int, tournament_info: str) -> None:
|
||||||
|
await self._db_service.set_tournament_info(tournament_id, tournament_info)
|
||||||
18
src/ez_lan_manager/types/Tournament.py
Normal file
18
src/ez_lan_manager/types/Tournament.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from datetime import date, datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Tournament:
|
||||||
|
tournament_id: int
|
||||||
|
tournament_name: str
|
||||||
|
tournament_info: str
|
||||||
|
participants_limit: int
|
||||||
|
start_time: datetime
|
||||||
|
created_at: datetime
|
||||||
|
can_register: bool = True
|
||||||
|
|
||||||
|
def __hash__(self) -> int:
|
||||||
|
return hash(str(self.tournament_id))
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user