refactor: remove Alembic migrations and Discord integration

This commit is contained in:
2026-07-15 15:55:25 +05:00
parent e8cff0f7ed
commit ec5ae395f3
24 changed files with 559 additions and 1718 deletions
+23 -17
View File
@@ -13,14 +13,17 @@ from tgbot.utils.const_functions import get_unix
class PositionModel(Base):
__tablename__ = "storage_position"
increment: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
increment: Mapped[int] = mapped_column(
Integer, primary_key=True, autoincrement=True
)
category_id: Mapped[int] = mapped_column(BigInteger, nullable=False, index=True)
position_id: Mapped[int] = mapped_column(BigInteger, nullable=False, index=True)
position_name: Mapped[str] = mapped_column(String(255), nullable=False)
position_price: Mapped[float] = mapped_column(Float, nullable=False, default=0)
position_desc: Mapped[str] = mapped_column(Text, nullable=False, default="None")
position_photo: Mapped[str] = mapped_column(Text, nullable=False, default="None")
position_unix: Mapped[int] = mapped_column(Integer, nullable=False, default=get_unix)
position_unix: Mapped[int] = mapped_column(
Integer, nullable=False, default=get_unix
)
ModelBase = Position
@@ -37,13 +40,12 @@ class Positionx(BaseRepository[PositionModel, Position]):
# Добавление позиции товара
async def add(
self,
category_id: int,
position_id: int,
position_name: str,
position_price: float,
position_desc: str,
position_photo: str,
self,
category_id: int,
position_id: int,
position_name: str,
position_price: float,
position_desc: str,
) -> Position:
return await self._insert(
category_id=category_id,
@@ -51,12 +53,13 @@ class Positionx(BaseRepository[PositionModel, Position]):
position_name=position_name,
position_price=position_price,
position_desc=position_desc,
position_photo=position_photo,
position_unix=get_unix(),
)
# Обновление позиции по ID или фильтру
async def update(self, where: Optional[Union[Dict[str, Any], int]] = None, **kwargs) -> int:
async def update(
self, where: Optional[Union[Dict[str, Any], int]] = None, **kwargs
) -> int:
if isinstance(where, int):
where = {"position_id": where}
@@ -68,12 +71,15 @@ class Positionx(BaseRepository[PositionModel, Position]):
from tgbot.database.db_item import ItemModel
item_table = ItemModel.__table__
statement = (
select(item_table.c.position_id, func.count(item_table.c.increment).label("item_count"))
.group_by(item_table.c.position_id)
)
statement = select(
item_table.c.position_id,
func.count(item_table.c.increment).label("item_count"),
).group_by(item_table.c.position_id)
async with session_scope() as session:
rows = await session.execute(statement)
return {int(position_id): int(item_count) for position_id, item_count in rows.all()}
return {
int(position_id): int(item_count)
for position_id, item_count in rows.all()
}