style(database): Fixed the issue with long function declarations
This commit is contained in:
@@ -77,9 +77,14 @@ class AIPredictionsRepository:
|
|||||||
logger.error(f"Ошибка получения последних прогнозов по товарам: {e}")
|
logger.error(f"Ошибка получения последних прогнозов по товарам: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def create_prediction(self, product_id: str, prediction_date: date,
|
def create_prediction(
|
||||||
days_until_stockout: int, recommended_order: int,
|
self,
|
||||||
confidence_score: float) -> Optional[int]:
|
product_id: str,
|
||||||
|
prediction_date: date,
|
||||||
|
days_until_stockout: int,
|
||||||
|
recommended_order: int,
|
||||||
|
confidence_score: float
|
||||||
|
) -> Optional[int]:
|
||||||
try:
|
try:
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
|
|||||||
@@ -48,8 +48,17 @@ class InventoryRepository:
|
|||||||
logger.error(f"Ошибка получения записи инвентаризации {record_id}: {e}")
|
logger.error(f"Ошибка получения записи инвентаризации {record_id}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def create_record(self, robot_id: str, product_id: str, quantity: int, zone: str,
|
def create_record(
|
||||||
row_number: int, shelf_number: int, status: str, scanned_at: datetime) -> Optional[int]:
|
self,
|
||||||
|
robot_id: str,
|
||||||
|
product_id: str,
|
||||||
|
quantity: int,
|
||||||
|
zone: str,
|
||||||
|
row_number: int,
|
||||||
|
shelf_number: int,
|
||||||
|
status: str,
|
||||||
|
scanned_at: datetime
|
||||||
|
) -> Optional[int]:
|
||||||
try:
|
try:
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# db/repositories/robot_repository.py
|
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
import logging
|
import logging
|
||||||
from db.connection import get_connection
|
from db.connection import get_connection
|
||||||
@@ -44,8 +43,15 @@ class RobotRepository:
|
|||||||
logger.error(f"Ошибка получения робота {robot_id}: {e}")
|
logger.error(f"Ошибка получения робота {robot_id}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def update_robot(self, robot_id: str, status: str = None, battery_level: int = None,
|
def update_robot(
|
||||||
current_zone: str = None, current_row: int = None, current_shelf: int = None) -> bool:
|
self,
|
||||||
|
robot_id: str,
|
||||||
|
status: str = None,
|
||||||
|
battery_level: int = None,
|
||||||
|
current_zone: str = None,
|
||||||
|
current_row: int = None,
|
||||||
|
current_shelf: int = None
|
||||||
|
) -> bool:
|
||||||
try:
|
try:
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
@@ -127,7 +133,12 @@ class RobotRepository:
|
|||||||
logger.error(f"Ошибка получения роботов в зоне {zone}: {e}")
|
logger.error(f"Ошибка получения роботов в зоне {zone}: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def create_robot(self, robot_id: str, status: str = 'active', battery_level: int = 100) -> bool:
|
def create_robot(
|
||||||
|
self,
|
||||||
|
robot_id: str,
|
||||||
|
status: str = 'active',
|
||||||
|
battery_level: int = 100
|
||||||
|
) -> bool:
|
||||||
try:
|
try:
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
|
|||||||
@@ -57,7 +57,13 @@ class UserRepository:
|
|||||||
logger.error(f"Ошибка получения пользователя по email {email}: {e}")
|
logger.error(f"Ошибка получения пользователя по email {email}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def create_user(self, email: str, password_hash: str, name: str, role: str) -> Optional[User]:
|
def create_user(
|
||||||
|
self,
|
||||||
|
email: str,
|
||||||
|
password_hash: str,
|
||||||
|
name: str,
|
||||||
|
role: str
|
||||||
|
) -> Optional[User]:
|
||||||
try:
|
try:
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
|
|||||||
Reference in New Issue
Block a user